我试图通过php发送这个json数据,并没有最好的运气。
curl --header 'Authorization: Bearer <token>' -X POST https://api.site.com --header 'Content-Type: application/json' --data-binary '{"email": "mail@mail.com", "type": "note", "title": "title", "body": "Note Body"}'
这就是我所拥有的:
curl_setopt_array($ch = curl_init(), array(
CURLOPT_HTTPHEADER => array("Authorization: Bearer <token>", "Content-Type: application/json"),
CURLOPT_URL => "https://api.site.com",
CURLOPT_POST => true,
CURLOPT_BINARYTRANSFER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => array(
"email" => "mail@mail.com",
"type" => "note",
"title" => "alert",
"body" => "body",
),
CURLOPT_SAFE_UPLOAD => true,
));
$response = curl_exec($ch);
curl_close($ch);
答案 0 :(得分:2)
试试吧
CURLOPT_POSTFIELDS => json_encode( array(
"email" => "mail@mail.com",
"type" => "note",
"title" => "alert",
"body" => "body",
)),