对PHP脚本调用的命令行cURL感到困惑

时间:2016-02-21 19:53:59

标签: php curl paypal

我正在尝试将此cURL命令行调用转换为PHP脚本。我已经阅读了很多关于它的文章,并尝试了几个选项但没有一个能够返回结果。这是命令行调用:

curl -v 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"

这是我到目前为止所尝试的内容:

$data = "grant_type=client_credentials";
$url = "https://api.sandbox.paypal.com/v1/oauth2/token";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER, array("Accept:application/json","Accept-     Language:en_US"));

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_USERPWD, "[$idclient]:[$sekret]");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($ch);

curl_close($ch);

echo $result;
var_dump($result);

请帮我将其转换为PHP脚本调用。

谢谢

1 个答案:

答案 0 :(得分:1)

let idx = myArray.index(where: { $0["required"] == false })