code that search for a username in flick using REST service of flickr.
//REST url for flickr
$url = "http://api.flickr.com/services/rest";
$data = array(
"username" => "sudhi",
"method" => "flickr.people.findByUsername",
"api_key" => "ur_api_key_here"
);
//this is the query string initialization
$q = http_build_query($data);
$finalUrl = $url."?".$q;
//initialize curl
$ch = curl_init($finalUrl);
//return the response as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//execute the curl
$result = curl_exec($ch);
//use simpleXml for parsing the xml response
$xmlStr = simplexml_load_string($result);
foreach($xmlStr->user as $people) {
$attrs = $user->attributes();
//ths $attrs contains user information
echo "";";
print_r($attrs);
echo "
}
No comments:
Post a Comment