PEAR::Flickr_API
INSTALLATION
- Install PEAR.
- At the command prompt, type "
pear install -of http://code.iamcal.com/php/flickr/Flickr_API-Latest.tgz
".
- If you don't have command line access, then just unzip this package into a folder in your include_path.
UPGRADING
- At the command prompt, type "
pear -d preferred_state=beta upgrade -of http://code.iamcal.com/php/flickr/Flickr_API-Latest.tgz
".
- If you don't have command line access, then just unzip this package into a folder in your include_path.
USAGE
require_once 'Flickr/API.php';
# create a new api object
$api =& new Flickr_API(array(
'api_key' => '1234567890',
));
# call a method
$response = $api->callMethod('flickr.test.echo', array(
'foo' => 'bar',
));
# check the response
if ($response){
# response is an XML_Tree root object
}else{
# fetch the error
$code = $api->getErrorCode();
$message = $api->getErrorMessage();
}
METHODS
void Flickr_API(array $params)
- The constructor takes an optional array of parameters as follows:
api_key
- Your Flickr API key
api_secret
- The auth secret tied to your API key (only needed for authenticated calls)
endpoint
- The Flickr REST endpoint (a sensible default is used when you don't specify one)
auth_endpoint
- The Flickr Auth endpoint (a sensible default is used when you don't specify one)
conn_timeout
- HTTP connection timeout in seconds (defaults to 5)
io_timeout
- HTTP IO timeout in seconds (defaults to 5)
XML_Tree callMethod(string $method, array $params)
- Calls the method
$method
with an optional array of parameters.
integer getErrorCode()
- Returns the error code for the last method call.
string getErrorMessage()
- Returns the error message for the last method call.
string getAuthUrl(string $perms, string $frob='')
- Returns a signed url to direct an authenticating user to. A frob only needs to be passed for non-web applications.