How do get Smugmug API & SessionId
test.iwave
Registered Users Posts: 3 Beginner grinner
I am web site developer. I am using " Smugmug API ". I created API key "
xxxx ".
I am using that URL "
http://api.smugmug.com/services/api/json/1.2.2/?method=smugmug.albums.get&SessionID=xxxxx"
. I got the following error message "
{"stat":"fail","method":"smugmug.albums.get","code":18,"message":"invalid
API key"} ".
How do i solve this problem. Please help me..
xxxx ".
I am using that URL "
http://api.smugmug.com/services/api/json/1.2.2/?method=smugmug.albums.get&SessionID=xxxxx"
. I got the following error message "
{"stat":"fail","method":"smugmug.albums.get","code":18,"message":"invalid
API key"} ".
How do i solve this problem. Please help me..
0
Comments
1) Get a session ID- Use smugmug.login.anonymously if you want to browse publicly avaliable images, or use one of the other login methods provided in the documentation. See the docs for the arguments.
2) Use the session ID that comes back from Smugmug there in every other command you send.
If you do that, it should work fine. Good luck!
Dear,
Thanks you for you guidelines. I am using CURL function. I got the Invalid user error ( error code 4 ) . How do i solve that problem ?
[PHP]
$ch = curl_init() or die(curl_error());
$chs = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,"http://api.smugmug.com/services/api/json/1.2.2/?APIKey=xxxxx&JSONCallback=jsonSmugmugApi&method=smugmug.login.anonymously");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
$str = preg_replace("/([a-zA-Z0-9_]+?):/" , "\"$1\":", $data1); // fix variable names
$output = json_decode($str, true);
echo "<pre>";
var_dump($output);
echo "</pre>";
$sessionid = $output;
curl_setopt($chs, CURLOPT_URL,"http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.get&SessionID=".$sessionid."&SitePassword=observer1");
curl_setopt($chs, CURLOPT_RETURNTRANSFER, 1);
$result_details =curl_exec($chs) or die(curl_error());
echo "<font color=black face=verdana size=3>".$result_details."</font>";
echo curl_error($chs);
curl_close($chs);
echo curl_error($ch);
curl_close($ch)
[/PHP]
SmugMug API Developer
My Photos