GV Streamer API Description


gvServerAPI v1.1- PHP


Prerequisits: PHP 5.2.0 or higher.
Full example is available here.

gvStreamer
Description: This is the only object that needs to be instantiated.
Parameters: None.
Example: $gvJsonObj = new gvStreamer();

init()
Description: Initializes the gvStreamer object before building the data source. init() must be called before any other function
Parameters: None.
Example: $gvJsonObj->init();

addColumn($id,$label,$type,$pattern="")
Description: Add column to the data source.
Parameters:
  • $id: string - Unique identifier of the column.
  • $lable: string - The label of the column.
  • $type: string - The type of the column. Can be: string, number, date, time, datetime, bool
  • $pattern: string, optional - The default pattern of the column. learn more on pattern format here.
Example: $gvJsonObj->addColumn("0","date","date", "M/d/yyyy");

addNewRow()
Description: Add new row to the data source.
Parameters: None.
Example: $gvJsonObj->addNewRow();

addEmptyCellToRow()
Description: Add cell with no value to the current row.
Parameters: None.
Example: $gvJsonObj->addEmptyCellToRow();

addStringCellToRow($value,$fValue=null)
Description: Add cell of type string to the current row.
Parameters:
  • $value: string - The value of the cell.
  • $fValue: string, optional - The formated value of the cell. For string cells this will usually left empty.
Example: $gvJsonObj->addStringCellToRow("chair");

addNumberCellToRow($value,$fValue=null)
Description: Add cell of type number to the current row.
Parameters:
  • $value: number - The value of the cell.
  • $fValue: string, optional - The formated value of the cell, that is, the value as it should be displayd.
Example: $gvJsonObj->addNumberCellToRow(200, "200.0");

addDateCellToRow($year, $month, $day,$hour=0, $minutes=0, $seconds=0, $fValue=null)
Description: Add cell of type date to the current row.
Parameters:
  • $year: number - 4 digits year.
  • $month: number - Month 1-12.
  • $day: number - The day of the month.
  • $hour: number, optional - Hour 0-23.
  • $minutes: number, optional - Minutes 0-59.
  • $seconds: number, optional - Secondes 0-59.
  • $fValue: string, optional - The formated value of the cell, that is, the value as it should be displayd.
Example: $gvJsonObj->addDateCellToRow(2007, 01, 12, 0, 0, 0, "1/12/2007");

addDatetimeCellToRow($year, $month, $day,$hour=0, $minutes=0, $seconds=0, $fValue=null)
Description: Add cell of type datetime to the current row
Parameters:
  • $year: number - 4 digits year.
  • $month: number - Month 1-12.
  • $day: number - The day of the month.
  • $hour: number, optional - Hour 0-23.
  • $minutes: number, optional - Minutes 0-59.
  • $seconds: number, optional - Secondes 0-59.
  • $fValue: string, optional - The formated value of the cell, that is, the value as it should be displayd.
Example: $gvJsonObj->addDatetimeCellToRow(2007, 01, 12, 0, 0, 0, "1/12/2007");

addTimeCellToRow($hour, $minutes, $seconds=0, $milisec=0, $fValue=null)
Description: Add cell of type time to the current row.
Parameters:
  • $hour: number - Hour 0-23.
  • $minutes: number - Minutes 0-59.
  • $seconds: number - Secondes 0-59.
  • $fValue: string, optional - The formated value of the cell, that is, the value as it should be displayd.
Example: $gvJsonObj->addDateTimeCellToRow(15, 30, 0, "3:30:00 PM");

addBoolCellToRow($value,$fValue=null)
Description: Add cell of type boolean to the current row
Parameters:
  • $value: boolean - true or false.
  • $fValue: string, optional - The formated value of the cell, that is, the value as it should be displayd.
Example: $gvJsonObj->addBoolCellToRow(false, "FALSE");

gvServerAPIEx v1.4 - PHP


Prerequisits: PHP 5.2.0 or higher.
Full example is available here.

Change Log:

gvServerAPIEx v1.4 - PHP

  • Add support for TSV (tab separated values) output
    Example: http://www.mydomain.com/salesDataSource.php?tqx=reqId:0;out:tsv;outFileName:sales
  • Add support for CSV/TSV file name via the 'tqx' parameter 'outFileName' also. This is done to support Google's protocol definition
  • Introducing new 'tqx' parameter: 'csvRawValues' for setting the CSV/TSV output to be with row values or formatted values
    Example: http://www.mydomain.com/salesDataSource.php?tqx=reqId:0;out:tsv;outFileName:sales;csvRawValues:yes


gvServerAPIEx v1.2 - PHP

  • Add support for CSV output. The API is now supports the URL parameter 'out'. When the value of this parameter is 'csv' the data will be saved as a CSV file. The API supports another URL parameter called 'csvFile'. This is a propriatary parameter that allows you to set the CSV file name. Both parameters are part of the protocol's 'tqx' parameter.
    Example: http://www.mydomain.com/salesDataSource.php?tqx=reqId:0;out:csv;csvFile:sales


gvServerAPIEx v1.1.1 - PHP

  • Fix minor bug that caused javascript warnings in date objects (Thanks Kenneth Cox)

gvServerAPIEx v1.1 - PHP

  • Add support for PostgreSQL queries auto-conversion

The extended API includes all the functions of the regular API with the following additions and changes.

gvStreamerEx
Description: This is the only object that needs to be instantiated.
Parameters: None.
Example: $gvJsonObj = new gvStreamerEx();

init($tqx=null, $resHandler=null)
Description: Initializes the gvStreamerEx object before building the data source. init() must be called before any other function
Parameters:
  • $tqx: string, optional - The tqx GET parameter from the request, without any change. Learn more on request parameters here.
  • $resHandler: string, optional - The responseHandler GET parameter from the request, without any change.
Example: $tqx = $_GET['tqx'];
    $resHandler = $_GET['responseHandler'];
    $gvJsonObj->init($tqx, $resHandler);


setColumnPattern($index, $pattern)
Description: Set the column default pattern.
Parameters:
  • $index: number - The index of the column
  • $pattern: string - The column pattern. Same as in addColumn().
Example: $gvJsonObj->setColumnPattern(0,"M/d/yyyy");

getColumnType($index)
Description: Returns the column type.
Parameters:
  • $index: number - The index of the column
Example: $type = $gvJsonObj->getColumnType(0);

convertMysqlRes(&$result, $numberFormat=null, $dateFormat=null, $timeFormat=null, $datetimeFormat=null)
Description: Converts an entire MySql query into a Google visualization compliant data source. Note: fields of type blob are ignored and not converted.
Parameters:
  • &$result: MySql query result object.
  • $numberFormat: string, optional - If the MySql result contains fields of types int, real or number, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
  • $dateFormat: string, optional - If the MySql result contains fields of types date or year, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
  • $timeFormat: string, optional - If the MySql result contains fields of types time, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
  • $datetimeFormat: string, optional - If the MySql result contains fields of types timestamp or datetime, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
Example: $gvJsonObj->convertMysqlRes(&$result, "%01.1f", "m/d/Y", "G:i:s", "m/d/Y:G:i:s");

convertPGRes(&$result, $numberFormat=null, $dateFormat=null, $timeFormat=null, $datetimeFormat=null)
Description: Converts an entire PostgreSQL query into a Google visualization compliant data source. Note: all fields with geometric types are ignored. and not converted
Parameters:
  • &$result: PostgreSQL query result object.
  • $numberFormat: string, optional - If the PostgreSQL result contains fields of number types or interval, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
  • $dateFormat: string, optional - If the PostgreSQL result contains fields of date types, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
  • $timeFormat: string, optional - If the PostgreSQL result contains fields of time types, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
  • $datetimeFormat: string, optional - If the PostgreSQL result contains fields of types timestamp, they will be formated according to this format. The format structure is the same as in PHP's printf() command.
Example: $gvJsonObj->convertPGRes(&$result, "%01.1f", "m/d/Y", "G:i:s", "m/d/Y:G:i:s");

getHashSig()
Description: Returns md5 hash value for the current data source. Usually there will be no need to call this fuction explicitly, as the signature feature is supported automatically.
Parameters: None.
Example: $sig = $gvJsonObj->getHashSig();

createError($reason, $msg="", $detailedMsg = "")
Description: Creates an error message in the protocol's proper format.
Parameters:
  • $reason: string - A one-word string description of the Error/warning. See protocol defined values here
  • $msg: string, optional - A short string explaining the problem.
  • $detailedMsg: string, optional - A detailed string message explaining the problem, and any possible solutions.
Example: $gvJsonObj->createError("not_modified", "Data not modified");

addWarning($reason, $msg="", $detailedMsg = "")
Description: Creates a warning in the protocol's proper format.
Parameters:
  • $reason: string - A one-word string description of the Error/warning. See protocol defined values here
  • $msg: string, optional - A short string explaining the problem.
  • $detailedMsg: string, optional - A detailed string message explaining the problem, and any possible solutions.
Example: $gvJsonObj->addWarning("other ", "Data may be not up to date");