我正在尝试使用 PHP(不使用客户端 API)对 PhotoBucket REST API 进行第一步身份验证。由于他们正在升级服务,开发人员站点已关闭,但他们为我提供了一个 SCID 和一个私钥,我认为这是客户密钥和客户密码。我一直在寻找文档和其他帖子,但没有运气。 https://stackoverflow.com/questions/7890518/register-user-by-php-in-photobucket
到目前为止,这是我想出的:
//default parameters
$url = "http://api.photobucket.com/login/request";
$parameters = array(
'oauth_consumer_key' => rawurlencode('**key**'),
'oauth_nonce' => rawurlencode(md5(time())),//no md5, "Authentication failed nonce invalid"
'oauth_signature_method' => rawurlencode('HMAC-SHA1'),
'oauth_timestamp' => rawurlencode(time()),
'oauth_version' => rawurlencode('1.0'),
'format' => 'json'
);
//creation of base string and signature
$basestring = rawurlencode("POST") . '&' . rawurlencode($url) . '&' . rawurlencode(http_build_query($parameters));
$sign = base64_encode(hash_hmac("sha1", $basestring, "**secret**" . "&", true));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($parameters) . '&oauth_signature=' . rawurlencode($sign));
$result = curl_exec($ch);
如果我将参数添加为 POSTFIELDS,我得到:401,异常身份验证失败时间戳无效 -1366125875 7 xml POST 1366125875
如果我添加示例中的参数 (url + ? + parameters + &signature=signature 我得到:401, Exception Authentication failed signature check failed 7 xml POST 1366125970
参考资料: http: //pic.photobucket.com/dev_help/WebHelpPublic/Content/Getting%20Started/Consumer%20Authentication.htm
http://feed7.com/ad-202021/Photobucket-Developer-Forum-Code-Examples-and-Libraries