我无法在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 :(得分: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