I am using the following code:
<?php
$token = $_REQUEST['token'];
$file = $_REQUEST['file'];
$sig = "xxxxxxxxxxxxxxxxxapi_keyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxauth_token" . $token;
$sign = md5($sig);
$url = "http://api.flickr.com/services/upload/";
$ch = curl_init();
/**
* Set the URL of the page or file to download.
*/
$body = "api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&api_sig=" . $sign . "&auth_token=" . $token . "&photo=" . $file;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
/**
* Ask cURL to return the contents in a variable
* instead of simply echoing them to the browser.
*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/**
* Execute the cURL session
*/
$contents = curl_exec ($ch);
/**
* Close cURL session
*/
curl_close ($ch);
echo $contents;
?>
to create my signature for the flickr upload post call. However, it keeps telling me its invalid....what am I doing wrong?
maybe you could have a quick look at my code?
You need to include all of the post parameters, except the photo
parameter, in the string (in alphabetical order) that you take the hash of.
See http://www.flickr.com/services/api/auth.spec.html#signing