douliedu335997 2010-07-31 00:24
浏览 46
已采纳

使用cURL / OAuth访问del.icio.us api

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?

  • 写回答

1条回答 默认 最新

  • doujiao4710 2010-07-31 17:06
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 换yum源但仍然用不了httpd
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal
  • ¥15 想用@vueuse 把项目动态改成深色主题,localStorge里面的vueuse-color-scheme一开始就给我改成了dark,不知道什么原因(相关搜索:背景颜色)
  • ¥20 OPENVPN连接问题
  • ¥15 flask实现搜索框访问数据库
  • ¥15 mrk3399刷完安卓11后投屏调试只能显示一个设备
  • ¥100 如何用js写一个游戏云存档
  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题