doudou8081 2012-04-04 15:08
浏览 42
已采纳

发布到Facebook Graph Api很慢

I am creating a new Facebook app and there are actions attached to it, like the 'Listening to xxx' on Spotify.

Trouble is that the call takes around 6-7 seconds which is quite a long time. Beneath my code is the results of curl_getinfo. Is it supposed to be this slow?

    $attachment = array(
        'access_token' => $access_token,
        'album' => 'sergeant peppers',
    );

    $opts = array(
        CURLOPT_CONNECTTIMEOUT => 10,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 60,
        CURLOPT_USERAGENT => 'facebook-php-3.1',
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $attachment,
        CURLOPT_URL => 'https://graph.facebook.com/me/APPNAME:listening'
    );
    $ch = curl_init();
    curl_setopt_array($ch, $opts);
    $result = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);

The results of curl_getinfo:

[url] => https://graph.facebook.com/me/APPNAME:listening
[content_type] => text/javascript; charset=UTF-8
[http_code] => 400
[header_size] => 557
[request_size] => 238
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 6.002449
[namelookup_time] => 0.024892
[connect_time] => 0.179322
[pretransfer_time] => 0.77444
[size_upload] => 362
[size_download] => 212
[speed_download] => 35
[speed_upload] => 60
[download_content_length] => 212
[upload_content_length] => 362
[starttransfer_time] => 1.775707
[redirect_time] => 0
[certinfo] => Array
    (
    )

[redirect_url] => 
  • 写回答

2条回答 默认 最新

  • dongxianghuan3587 2012-04-09 21:33
    关注

    Well, you have gotten a http 400 return (bad request), which indicates something went wrong. Maybe if you get your request right the request will be faster?

    This post: php cURL error in facebook api indicates that you should remove 'CURLOPT_POST => true' I also suggest adding 'CURLOPT_VERIFYPEER => false' if you still have problems.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!