2014-05-22 113 views
0

如何連接到Instagram API使用PHP來驗證用戶,當我來到服務器他的數據?在此先感謝通過php連接到instagram API

+0

我們會需要更多一點的工作。你有沒有開始的東西不符合你的想法? – complex857

+0

我已閱讀文檔,但沒有任何理解) – user3663565

回答

2

首先,你需要registrate您的應用程序: http://instagram.com/developer/clients/manage/

接下來在PHP處理程序:

$url = "https://api.instagram.com/oauth/access_token"; 
$access_token_parameters = array(
    'client_id'    =>  '%client_id%', 
    'client_secret'   =>  '%client_secret%', 
    'grant_type'    =>  'authorization_code', 
    'redirect_uri'    =>  'http://domain.com/index.php', 
    'code'      =>  $code 
); 
$curl = curl_init($url); // we init curl by passing the url 
curl_setopt($curl,CURLOPT_POST,true); // to send a POST request 
curl_setopt($curl,CURLOPT_POSTFIELDS,$access_token_parameters); // indicate the data to send 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly. 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // to stop cURL from verifying the peer's certificate. 
$result = curl_exec($curl); // to perform the curl session 
curl_close($curl); // to close the curl session 

$user_data = json_decode($result,true); 
+0

非常感謝,這正是我們所需要的。請原諒我的無知! – user3663565

+1

不客氣! – SergeevD