JSONがひどくフォーマットされ、無効な文字のPHPのカールが含まれているか、無効な文字が含まれている、いくつかの提案を試してみましたが、それでも、これは次のように助けてください、同じエラーを受信カールエラーがひどくフォーマットされているか、それが
完全なを使用して、私のJSONの投稿ですカール要求
$url='https://sandbox.interswitchng.com/api/v2/quickteller/payments/transfers';
$postdata='{
"mac":"9F4E4F53C57BE63E1F08D8F07A7BC1A9461E4A7D5304043DAA1EF54BD727B6CDE148F4FBFC5E2AD8C4A60F78DFA76304DE671FBEB70657B1628F14B6B6BAA5E1",
"beneficiary":{
"firstname":"chi",
"lastname":"chi",
"othernames":"chi"
},
"initiatingEntityCode":"FIB",
"initiation":{
"amount":"100000",
"channel":"7",
"currencyCode":"566",
"paymentMethodCode":"CA"
},
"sender":{
"email":"[email protected]",
"lastname":"Phil colins",
"othernames":"Phil colins",
"phone":"08124888436"
},
"termination":{
"accountReceivable":{
"accountNumber":"0012000887",
"accountType":"10"
},
"amount":"100000",
"countryCode":"NG",
"currencyCode":"566",
"entityCode":"058",
"paymentMethodCode":"AC"
},
"transferCode":"1016858652542545"
}';
$data=json_encode(json_decode($postdata));
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json'
));
$result = curl_exec($ch);
echo curl_getinfo($ch) . '<br/>';
echo curl_errno($ch) . '<br/>';
echo curl_error($ch) . '<br/>';
var_dump($result);
が、それでもJSONがひどくフォーマットされているか、無効な文字が含まれているエラー を受けます。
JSONの構文は(https://jsonlint.comでテスト)正しいように思えます。受信側のサーバーが読み取ることができない「意味上のエラー」はありますか?カールリクエストのPHPコードを表示できますか? – BenRoob
はい、私も試しました。それは正常に動作します –
あなたは実際にこのJson文字列で何を試していますか? このJson文字列を独自に作成する場合は、このようなエラーを避けるために削除します。独自のJson文字列を作成する代わりに、まずjson_encode()を使用してJsonスティングを作成します。 – Mukesh