Facebook API - 本地主机和生产的不同结果。达到申请要求限额

时间:2015-01-10 00:09:02

标签: php facebook facebook-graph-api

我有以下代码段:

$post_ids = array("307781172646235_739219686169046");
$quoted_post_ids = array();
foreach ($post_ids as $id) {
  $quoted_post_ids[] = '"' . $id . '"';
}


$fql = urlencode(
  "SELECT attachment FROM stream WHERE post_id IN(" . implode(',', $quoted_post_ids) . ")" 
);  

$all_photos_url = 'https://graph.facebook.com/fql?q=' . $fql . '&access_token=' . "XXXXXXXX";
$all_photos_result = drupal_http_request($all_photos_url);
$all_photos = json_decode($all_photos_result->data);
dpm($all_photos);
$actual_post = NULL;

foreach ($all_photos->data as $k => $post) {
  $actual_post = array();;

  foreach ($post->attachment->media as $photo) {
    if (isset($photo->photo)) {
      $photo_url = 'https://graph.facebook.com/' . $photo->photo->fbid;
      $photo_result = drupal_http_request($photo_url);
      $photo_info = json_decode($photo_result->data);
      if (isset($photo_info->images[0])) {
    $candidate_pic_url = $photo_info->images[0]->source;
    if (!empty($candidate_pic_url) && valid_url($candidate_pic_url)) {
      if (!isset($actual_post['picture_big'])) {
        $actual_post['picture_big'] = array();
      }
      $actual_post['picture_big'][] = $candidate_pic_url;
      $actual_post['picture_metadata'][] = $photo_info;
    }
      }
      usleep(500);
    }
  }

  dpm($actual_post);
}

dpm()只是一个Drupal特定的调试助手,可以输出变量。所以问题在于,如果我在localhost或登台服务器上执行它,它可以工作,但在生产时,我没有始终通过图形API获得图像。有时,我有,有时我没有。它是Gandi(https://www.gandi.net/hosting/simple)的共享主机。共享主机本身可能会受到速率限制吗?

更新: 在生产时,第二个HTTP请求给出:"达到应用程序请求限制" OAuth例外

0 个答案:

没有答案