1
我想通過php發送這個json數據,並沒有最好的運氣。轉換curl命令行到php代碼
curl --header 'Authorization: Bearer <token>' -X POST https://api.site.com --header 'Content-Type: application/json' --data-binary '{"email": "[email protected]", "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" => "[email protected]",
"type" => "note",
"title" => "alert",
"body" => "body",
),
CURLOPT_SAFE_UPLOAD => true,
));
$response = curl_exec($ch);
curl_close($ch);
謝謝,這是問題。就在我沒看的地方。如果可以的話,我會加倍努力。 – bbglazer
沒問題,很高興我能幫忙;-)你可以接受這個答案:-) –