2013-06-24 49 views
4

我正在嘗試使用Instagram API跟蹤用戶數組(通過他們的ID)。我正在使用此處記錄的最後一個端點:http://instagram.com/developer/endpoints/relationships/。發送請求後,我收到一些數據(代碼:200,incoming_status:「none」,outgoing_status:「none」)。Instagram API:關注問題

這裏是代碼片段(JavaScript的使用jQuery):

var access_parameters = {action:"follow"}; 
for (key in users) { 
    if (users.hasOwnProperty(key)) { 
     var username = key; 
     var instagramUrl = "https://api.instagram.com/v1/users/"+users[key][0]+"/relationship?access_token=[ACCESS_TOKEN]"; //where users[key][0] is the id of the user intended to follow and [ACCESS_TOKEN] is my access token 
     $.ajax({ 
     type:"POST", 
     async: false, 
     dataType: 'jsonp', 
     url: instagramUrl, 
     contentType: 'text/plain; charset=UTF-8', 
     data: access_parameters 
     }).done(function (data) { 
     if(console && console.log) { 
      console.log(data); //this is where the above data comes through 
     } 
     }); 
    } 
} 

我試圖把數據陣列中並且在URL中的access_token,也同樣與動作=幾個排列「跟隨」。似乎端點沒有收到操作參數,只是簡單地返回當前關係的狀態。

+0

您是否在註冊您的應用程序時爲關係提供了範圍? incoming_status:「none」,outgoing_status:「none」表示您向instagram發送的請求,但是由於權限無效,因此未處理。 – 2014-02-24 14:13:08

+0

你應該使用post方法不行。您應該添加操作作爲參數和值。您無法訪問關係端點而無需請求訪問端點,顯然您應該填寫表單。請讓我知道你填寫表格,因爲我有同樣的問題 – hadi

回答

1

我有同樣的錯誤。如果你看看來自開發者工具欄的網絡調用,我敢打賭你正在爲用戶關係做一個GET請求,並且服務器正在返回這些數據。

您需要提供// action = {follow,unfollow,block,unblock,approve,deny}中的一個。

我正在閱讀很多針對POST請求的客戶端CORS問題,特別是關於POST的關係。