I am using piwigo.com
I have tried using the API and I have managed to get some information back, but I seem to have done something stupid with regard to Tags, as the command I am using is returning.
array(3) { ["stat"]=> string(4) "fail" ["err"]=> int(401) ["message"]=> string(13) "Access denied" }
I probably do not understand the curl functions correctly as the remote call executes fine as a browser url
The first two curl requests work OK, it is the third one in the function getTags()
<?php function getTags ($session) { curl_setopt($session, CURLOPT_URL, 'http://mysite.piwigo.com/ws.php?format=php&method=pwg.tags.getAdminList'); curl_setopt($session, CURLOPT_HEADER, 0); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = unserialize($response); varDump($response,"Get.Tags.Admin"); } function varDump($r, $msg) { echo '<h3>' . $msg. '</h3>';; var_dump($r); echo '<hr>'; } $session = curl_init(); curl_setopt($session, CURLOPT_URL, 'http://mysite.piwigo.com/ws.php?method=pwg.categories.getImages&format=php&recursive=true&order=random&f_with_thumbnail=true&per_page=1&page=0'); curl_setopt($session, CURLOPT_HEADER, 0); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = unserialize($response); varDump($response,"Get.images.Random"); if ($response["stat"]=='ok') { $picture_id = $response["result"]["images"]["_content"][0]['id']; curl_setopt($session, CURLOPT_URL, 'http://mysite.piwigo.com/ws.php?method=pwg.images.getInfo&format=php&image_id='.$picture_id); $response = curl_exec($session); $response = unserialize($response); varDump($response,"Get.image.Info"); if ($response['stat']=='ok') { $picture = $response['result']; // <a href="http://mysite.piwigo.com/picture.php?/'.$picture['id'].'"><img src="'.$picture['derivatives']['thumb']['url'].'" alt="'.$picture['name'].'" border="0" /></a></center>'; echo ' <a href="http://mysite.piwigo.com/picture.php?/'.$picture['id'].'"><img src="'.$picture['derivatives']['square']['url'].'" alt="'.$picture['name'].'" border="3" width="80px" /></a></center>'; echo '<a href="'. $picture['derivatives']['medium']['url'] . '"><img src="'.$picture['derivatives']['square']['url'].'" alt="'.$picture['name'].'" border="3" width="80px" /></a></center>'; } } getTags($session); curl_close($session); ?>
Any pointers to what I have done wrong / misunderstood would be appreciated
Offline
I think you must login first, with the method pwg.session.login (as pwg.tags.getAdminList is an admin only method)
Offline
Hi There,
Many thanks for your help.
It worked, but you must use POST method.
mcl
Offline
as written in tools/ws.htm yes :)
Offline