0

エラー:

{"jsonrpc":"2.0","id":0,"error":{"code":1,"message":"Parameters missing or not sent as an JSON array. "}}

私のコード:

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Accept: text/plain, */*; q=0.01")); 
curl_setopt($ch, CURLOPT_URL, 'http://example.com/rpc/ClientApi?_session=XX');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('method' => 'AdsApi.giveAdLifeByCategory','params' => '["Ads4Life"]', 'id' => '0')));
curl_setopt($ch, CURLOPT_POST, 1); 
$result = curl_exec($ch);

?>

このリクエストをエミュレートしようとしています:

[{"method":"AdsApi.giveAdLifeByCategory","params":["Ads4Life"],"id":0}]

正解:

[{
     "jsonrpc": "2.0",
     "id": 0,
     "result": {
         "status": true,
         "timeStamp": 0
     }
}]

何が問題なのですか?

4

1 に答える 1