2015-11-12 81 views
0

我在訂閱一些用戶在Instagram上有幾個問題。訂閱挑戰正常工作,大部分用戶都已訂閱。他們的更新完全按預期工作。實時圖片更新 - 用戶訂閱

documentation有'myVerifyToken'我假設這是訂閱用戶的令牌,或者這是我創建發送的隨機唯一字符串?

下面是結果我得到一次我已經訂閱:

{"meta":{"code":200},"data":{"object":"user","object_id":null,"aspect":"media","callback_url":"http:\/\/urlmremoved\/instagram","type":"subscription","id":"000000000"}} 

這是告訴我,一個用戶訂閱已經成功然而,有6人加入後,我的應用程序並完成OAuth過程成功唯一的郵政我收到來自要認證的第一個成員......

訂閱代碼(對於大多數用戶來說做工不錯):

$checkin_url = "https://api.instagram.com/v1/subscriptions/"; 

     //$instagram[] for client_id, client_secret, redirect_uri 
     $parameters = array(
      'client_id' => '{key}', 
      'client_secret' => '{secret}', 
      'object' => 'user', 
      'aspect' => 'media', 
      'verify_token'=>$access_token, 
      'callback_url' => '{callback url}' 
     ); 

     $curl = curl_init($checkin_url); 
     curl_setopt($curl, CURLOPT_POST, true); 
     curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters); 
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
     $response = curl_exec($curl); 
     curl_close($curl); 
     $data = json_decode($response,false); 

傳入P OST腳本(很好地工作):

// Catches realtime updates from Instagram 
    if ($_SERVER['REQUEST_METHOD']==='POST') { 
     // Retrieves the POST data from Instagram 
     $update = file_get_contents('php://input'); 
     $data = json_decode($update); 

     foreach($data as $k => $v) {// can be multiple updates per call 
     // load temp items into the database. 
      $sub_id = $v->subscription_id; //Contains the JSON values 
      $user = $v->object_id; 
      $time = $v->time; 
      $changed = $v->changed_aspect; 

      $sql = "INSERT INTO temp (tempId,tempCode,tempData1,tempData2,tempData3,tempData4,tempLong,tempTime) 
        VALUES (NULL, 'IG', '".$changed."', '".$_SERVER['REMOTE_ADDR']."', '".$sub_id."', '".$time."', '".$update."', CURRENT_TIMESTAMP)"; 

      $account->mysql_Query($sql); 

     } // END foreach. 

    } // END if 

回答

0

Instagram只爲所有提供客戶端API權限的用戶提供實時更新。訂閱該端點時,您將開始接收已經授權的帳戶的更新。在另一個用戶授權後,您將收到這些回調,而無需再次訂閱。

從Instagram的文檔:
At the current moment we only allow you to subscribe to all users that have authenticated your application - not individual users.

+0

所以你的意思已經證實了我在看書。我只向用戶訂閱**一次**,然後任何通過oAuth進程的用戶都會自動添加。一些用戶已經完成了認證過程,但他們的實時帖子不會被推送。 – Philip

+0

您只訂購一次對象 - >用戶與aspect->媒體,然後您獲得所有auth'd用戶職位。不過,我遇到了類似的問題,其中有許多來自已授權用戶的已跳過帖子。 – ggwarpig