使用cURL/OAuth访问del.icio.us api
我正在按照本教程访问del.icio.us api,但这是我第一次使用 cURL 或 OAuth 因此遇到了一些障碍。
我
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_nonce=123456789&oauth_timestamp="+$timestamp+"&oauth_consumer_key="+$consumerKey+"&oauth_signature_method=plaintext&oauth_signature="+$secret+"&oauth_version=1.0&xoauth_lang_pref=en-us&oauth_callback=http://www.chris-armstrong.com/paperclip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$contents = curl_exec ($ch);
curl_close ($ch);
根据教程使用以下代码,这应该返回类似以下内容的内容
oauth_token%3Drpfbncv%26oauth_token_secret%3D5f2e792b36c40edaf7bdd8fb10b6edd1fde87a52%26oauth_expires_in%3D3600%26xoauth_request_auth_url%3Dhttps%253A%252F%252Fapi。 login.yahoo.com%252Foauth%252Fv2%252Frequest_auth%253Foauth_token%253Drpfbncv%26oauth_callback_confirmed%3Dtrue
但是当我尝试回显 $contents 时,它返回空白。有什么想法吗?
I'm following this tutorial to access the del.icio.us api, but this is my first time using cURL or OAuth so hitting a few snags.
I'm using the following code
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_nonce=123456789&oauth_timestamp="+$timestamp+"&oauth_consumer_key="+$consumerKey+"&oauth_signature_method=plaintext&oauth_signature="+$secret+"&oauth_version=1.0&xoauth_lang_pref=en-us&oauth_callback=http://www.chris-armstrong.com/paperclip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$contents = curl_exec ($ch);
curl_close ($ch);
according to the tutorial, this should return something like the following
oauth_token%3Drpfbncv%26oauth_token_secret%3D5f2e792b36c40edaf7bdd8fb10b6edd1fde87a52%26oauth_expires_in%3D3600%26xoauth_request_auth_url%3Dhttps%253A%252F%252Fapi.login.yahoo.com%252Foauth%252Fv2%252Frequest_auth%253Foauth_token%253Drpfbncv%26oauth_callback_confirmed%3Dtrue
but when I try to echo $contents, it returns blank. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,事实证明我的主要错误是使用“+”而不是“。”将不同的字符串添加在一起。另外,秘密似乎需要 %26 之后,但不知道为什么。
Ok turns out my main mistake was to use '+' instead of '.' to add different strings together. Also, the secret seems to require %26 after it, not sure why though.