api — PHP curl с многочастной границей и смешивание с приложением / json и текстом / plain

Я пытаюсь опубликовать данные, чтобы отдохнуть API с curl

мои параметры: «appkey», «appsecret», «data»
rest api позволяет использовать тип содержимого text / plain для appkey, appsecret
и позволяет приложение / JSON для данных

когда я использую программное обеспечение restClient, приходит успешный ответ.
но когда я использую php curl приходя 500 внутренняя ошибка сервера.

мои коды

<?php
$boundary= '--7ZAUH3KVUpvXgwagBLkB4v7r84QBpj0TxAvNF
Content-Disposition: form-data; name="appsecret"Content-Type: text/plain; charset=UTF-8

xxxxxxxxxx
--7ZAUH3KVUpvXgwagBLkB4v7r84QBpj0TxAvNF
Content-Disposition: form-data; name="appkey"Content-Type: text/plain; charset=UTF-8

xxxxxxxxxx
--7ZAUH3KVUpvXgwagBLkB4v7r84QBpj0TxAvNF
Content-Disposition: form-data; name="data"Content-Type: application/json; charset=UTF-8
Content-Transfer-Encoding: 8bit

{"status":"New","buyerName":"","orderNumber":"","productId":"","productSellerCode":"","receipient":"","period":{"startDate":"01/01/2015 00:00","endDate":"27/01/2015 00:00"}}
--7ZAUH3KVUpvXgwagBLkB4v7r84QBpj0TxAvNF--';

$headers= array(
"Host: api.xxx.com",
"Content-Type: multipart/form-data; boundary=7ZAUH3KVUpvXgwagBLkB4v7r84QBpj0TxAvNF",
"User-Agent: Apache-HttpClient/4.2.1 (java 1.5)",
"Content-Length: " . strlen($boundary),
"Connection: Keep-Alive");

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'https://api.xxx.com/rest/secure/order/list.json');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER  ,1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $boundary);

$response = curl_exec($curl);

print_r($response);

есть конфигурации restClient

http://tinypic.com/r/ifuctz/8

что я должен сделать пост поля отдыха API с PHP Curl

Спасибо за ответы.

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector