2017-11-25 137 views
0

我找不到在PHP捲曲相當於此命令Instagram的API捲曲代碼命令到PHP

curl -F 'client_id=CLIENT_ID' \ 
 
    -F 'client_secret=CLIENT_SECRET' \ 
 
    -F 'grant_type=authorization_code' \ 
 
    -F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \ 
 
    -F 'code=CODE' \ 
 
    https://api.instagram.com/oauth/access_token

我知道它應該開始像

$ch = curl_init('https://api.instagram.com/oauth/access_token'); 
 
curl_setopt($ch, something, ...); 
 
... 
 
...

回答

0

其中的當量與

curl -F 'client_id=CLIENT_ID' \ 
    -F 'client_secret=CLIENT_SECRET' \ 
    -F 'grant_type=authorization_code' \ 
    -F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \ 
    -F 'code=CODE' \ 
    https://api.instagram.com/oauth/access_token 

$url = 'https://api.instagram.com/oauth/access_token'; 
$fields = array(
    'client_id' => 'CLIENT_ID', 
    'client_secret' => 'CLIENT_SECRET', 
    'grant_type' => 'authorization_code', 
    'redirect_uri' => 'AUTHORIZATION_REDIRECT_URI', 
    'code' => 'CODE' 
); 

$ch = curl_init(); 

curl_setopt($ch,CURLOPT_URL, $url); 
curl_setopt($ch,CURLOPT_POST, count($fields)); 
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); 

$result = curl_exec($ch); 

curl_close($ch); 

希望我幫助! -CM

+0

但什麼是$ fields_string?你的意思是$字段? –