Paypal アダプティブ ペイメントのAPI ドキュメントを見つけようとしています。だから私はこのcurlコマンド(例)を翻訳しようとしています:
curl https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" \
-d "grant_type=client_credentials"
php に (表示されていないのは、私の clientID とシークレットだけです):
$data =
'client_id=' . $clientID . '&' .
'client_secret=' . $clientSecret . '&' .
"grant_type=client_credentials";
$url = "https://api.sandbox.paypal.com/v1/oauth2/token";
$headers = array(
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
"grant_type=client_credentials"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERPWD, $clientID . ':' . $clientSecret);
$x = json_decode(curl_exec($ch));
var_dump($x);
これは次のように表示されます:
object(stdClass)#1 (2) { ["error"]=> string(22) "unsupported_grant_type" ["error_description"]=> string(22) "Unsupported grant_type" }
私は何を台無しにしていますか?ポインタ、ディレクティブ、またはヒントはありますか? 私は 3 日間ドキュメントを調べてきましたが、非常に乾燥しており、適切なチュートリアルが存在しないようです。ありがとう。