Friday, January 25, 2008

Accessing Flicker REST API

Accessing Flicker rest API using php is very simple. All what is needed is to construct the arguements array with the url and invoke the query. You can use the file_get_contents function to do the invocation.

For example, to invoke the flicker.photos.getRecent method , you can you the following code sample.

"flickr.photos.getRecent",
'api_key' => "your api key goes here");

foreach ($params as $key => $value) {
$query_string .= "$key=" . urlencode($value) . "&";
}

$url = "$base_string?$query_string";

$output = file_get_contents($url);

echo $output;

?>

you can use the urlencode function to encode the array of parameters and send then use the file_get_contents function to send the reqeust.

No comments:

Post a Comment