Class Documentation

This document is meant as quick reference to the freebase class methods. The class itself is very simple thanks to the use of the cURL library which is now included in PHP 5.x releases. You should find the library simple to use.

 

Class Name: Freebase

Purpose: Freebase class library allows quick and simple querying of the Google/Meta Web Freebase Metabase. This class provides a query facility for Php programmers. Alowing complex MQL queries to be build from Php arrays.

ver: 1.1.0

 

Class Methods

__construct(): Class constructor. Sets the api end point to the standard api.freebase.com

public setApiEndPoint(url): Provides a method to manually set the api end point. Takes a url as a string.

setSandbox(sandbox_mode=true): Tells the class to use the Freebase sandbox api end point. Use this when developing queries. Passing a value of true set the sandbox mode. passing false restores the production mode.

isSandbox(): returns true is sandbox mode is set. false otherwise.

setTimeout(tm): Sets the cURL connection timeout parameter. The passed value must be an integer value of seconds to wait before timing out. cURL adds one second to the passed value.

setFollow(): By default cURL doesnot follow host redirects. This method allows you to tell cURL to follow any host redirects. Pass true to follow and false to error on redirect.

addQuery(query_array): Adds a MQL query formed as a Php array to the query evelope and returns the query index. See the example code for details of building queries as Php array objects.

removeQuery(query_index): Removes the query at query_index from the query envelope.

get(mode): Makes a connection to the Freebase Api and executes the queries in the query list. Multiple queries are executed in paralelle for speed and effeciency. The mode parameter if passed must be one of the legal return types. See Query Return Types for more information.

getCursor(): Returns the MQL result cursor. The cursor can be used to paging through results. Freebase only allows 100 results to be returned as in a single query. By using the cursor you can make multiple calls to get each successive page of results.

getPageSize(): Returns the current results page size or number of result records.

getErrors(): Returns any query errors or false if no errors occured.

hasError(): Returns true if query errors occured. False otherwise.

getMessage(): Returns the query error message.

getStatus(): Returns the query result status.

 

Return Types:

The Freebase library can return query results in many forms based on the parameter passed to the get() method. These are as follows:

ParameterReturns
array Returns a Php array result
assoc Returns an associative array result
bool Returns a boolean true value if a result exists
json Returns a JSON (Javascript Object) object result
object Returns a Php object result
string Returns the query results as a string
default If no return type is passed to the get() method the results are returned as a Php associative array

 

 

News & Updates

Get The Source Code

Source code for this project may be available as downloads or through one of the SCM repositories used by the project, as accessible from the project develop page. More>>

Developers

Join This Project To join this project, please contact the project administrators of this project, as shown on the project summary page. More>>

Project Details

About this project:

This project was registered on SourceForge.net on:

Jan 28, 2010

The phpfreebase project is described by the project team as follows:

"A Php class library to query and write data to the Freebase Open Database System."

Web Designer

If you are a web page designer interested in this project, please consider reaching out to the project admin (per the "Join this project" section, above) to offer your assistance.