通过PHP curl使用Paypal连接的路径预先登录
我将继续学习本教程,拨打合作伙伴推荐电话 这是我在PHP上使用的代码通过PHP curl使用Paypal连接的路径预先登录,php,curl,paypal,Php,Curl,Paypal,我将继续学习本教程,拨打合作伙伴推荐电话 这是我在PHP上使用的代码 <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.sandbox.paypal.com/v2/customer/partner-referrals', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING =>
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.sandbox.paypal.com/v2/customer/partner-referrals',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{
"tracking_id":"MyTrackingId",
"operations": [
{
"operation": "API_INTEGRATION",
"api_integration_preference": {
"rest_api_integration": {
"integration_method": "PAYPAL",
"integration_type": "THIRD_PARTY",
"third_party_details": {
"features": [
"PAYMENT",
"REFUND",
]
}
}
}
}
],
"products": [
"EXPRESS_CHECKOUT"
],
"legal_consents": [
{
"type": "SHARE_DATA_CONSENT",
"granted": true
}
]
}',
CURLOPT_HTTPHEADER => array(
'accept-language: en_US',
'authorization: Bearer MySecretCode',
'content-type: application/json',
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo '<pre>';
print_r(json_decode($response));
echo '</pre>';
}
echo '<hr>';
不知道我做错了什么。我不确定它是否与
CURLOPT\u POSTFIELDS
中的代码有关。我试着修改它并使用在线curl-to-PHP转换器,但问题仍然是一样的。json无效“退款”,
@lawrencerone谢谢你回复我。。。我尝试了一个JSON验证器,但我被那个错误卡住了。我怎样才能修复它呢?请删除尾随的,
json无效“退款”,
@lawrencerone谢谢你回复我。。。我尝试了一个JSON验证器,但我被那个错误卡住了。如何修复它?请删除尾随的,
stdClass Object
(
[name] => INVALID_REQUEST
[message] => Request is not well-formed, syntactically incorrect, or violates schema.
[debug_id] => 9e151f0c8c5f0
[information_link] =>
[details] => Array
(
[0] => stdClass Object
(
[issue] => INVALID_PARAMETER_SYNTAX
[description] => Referral data is not a valid json object.
)
)
[links] => Array
(
)
)