0
私はAPIを呼び出すためのcURLのスニペットを作成してください。PHP cURL、API呼び出しスクリプトの作成のヘルプ
ご協力いただければ幸いです。
これはAPIコール
POST https://api.passes.com/v1/templates/names/Member%20Card/pass
どうやら彼らは、次は私がすべてではcURLに配置するかわからないです
------------------------------330184f75e21
Content-Disposition: form-data; name="values"; filename="values.json"
Content-Type: application/json
{
"firstName": "John",
"lastName": "Doe",
}
------------------------------330184f75e21
Content-Disposition: form-data; name="icon"; filename="icon.png"
Content-Type: application/octet-stream
imagedata
------------------------------330184f75e21
Content-Disposition: form-data; name="[email protected]"; filename="[email protected]"
Content-Type: application/octet-stream
imagedata
を送っ必要です。
私は以下のことを成功させることなく試しました。
$url1 = 'https://api.passes.com/v1/templates/names/Test/pass';
$data1 = array("values" => '{"first":"John","last":"Doe"}','application/json',
"strip" => '@../uploads/icon.png','application/octet-string','icon.png',
"[email protected]" => '@../uploads/icon.png','application/octet-string','icon.png');
$auth1 = array( "authorization: Basic xxxxxxxxxxxx=", "cache-control: no-cache", "postman-token: xxxxxxxxx");
$ch1 = curl_init($url1);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_POST, 1);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $data1);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $auth1);
$response1 = curl_exec($ch1);
echo $response1;
誰もがそれは素晴らしいだろう手助けができればそれは無効なJSON
を言っレスポンスで応答します。
ロブ
はまだJSONエラーを思い付く:( –
[OK]を、それは何を送ることは、有効なJSON形式ではなく、彼らが期待するものから無効なデータ構造であることを意味するようにします。 – JesusTheHun