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.

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

报告相同问题?

悬赏问题

  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题