After having just finished to code to revamp the way this site brings the photos in from Flickr, I think it might be worthwhile to share how that is done. I use JQuery for all my javascripting needs. Now it may be overkill for some tasks, but it is a relatively small file to import and saves me a lot of time and cross-browser headaches. This is no tutorial by any means (getting the token from Flickr would require pages of explanation). I really just wanted ot post snippets of my code here for reference. Here is goes:
<?php
if(!Empty($_GET)){
$secret = <from flickr>;
$_GET["api_key"] = <from flickr>;
$_GET["perms"] = "read";
if($_GET['url'] == "auth"){
$url = "http://flickr.com/services/auth/";
//the idea here was to break out the code to get the token.
//never tested since I did it manually.
}
else{
//hardcoded here from previous calls to api
$_GET["auth_token"] = <from flickr api calls>;
//this makes it easier to use the data once it's brought back into jquery
$_GET["nojsoncallback"] = "1";
$_GET["format"] = "json";
$url = "http://flickr.com/services/rest/";
}
// CREATE QUERY STRING AND API_SIG
ksort($_GET);
$sigString = $secret;
$queryString = "?";
foreach($_GET as $key => $value){
$sigString .= $key.$value;
$queryString .= $key . "=" . $value . "&";
}
//querystring: all of the $_GET values and appended with the api_sig
$sig = md5($sigString);
$queryString = $queryString . "api_sig=" . $sig;
$url .= $queryString;
if($_GET['url'] == "auth"){
echo $url;
}
else{
echo file_get_contents($url);
}
}
?>
a standard jQuery call from the main page would look similar to
$.getJSON("callFlickr.php", {method: "flickr.photosets.getList"},function(data){
//do stuff with the photoset list here
});
Hope this helps someone out there.
Mike