curl -v -S -u devuser:devuser123 \
-F 'notification={"applicationId":"32768","schemaId":"32771","topicId":"32768","type":"USER"};type=application/json' \
-F file=@notification.json \
'http://localhost:8080/kaaAdmin/rest/api/sendNotification'
私はそれをPHPに変換しようとしましたが、次のように終了しました:
$notification = array("applicationId" =>"32768",
"schemaId"=>"32771",
"topicId"=>"32768",
"type"=>"USER");
$ch = curl_init();
$headers = array();
$headers[] = 'Authorization: Basic ZGV2dXNlcjpkZXZ1c2VyMTIz';
$headers[] = 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryzeZR8KqAYJyI2jPL';
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8080/kaaAdmin/rest/api/sendNotification');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'notification='.json_encode($notification).'&file='.realpath('notification.json'));
$content = curl_exec($ch);
print $content;
curl_close($ch);
パラメータ「通知」と「ファイル」の設定方法がわかりません。解決策を教えてください。
ありがとうございました!