pisze obsluge allegro api i stanalem na wysylaniu pliku metoda binarna do allegro. Taki jest ich przyklad:
Kod
curl -X POST \
'https://upload.allegro.pl/sale/images
-H 'authorization: Bearer {token}' \
-H 'accept: application/vnd.allegro.beta.v1+json’ \
-H 'content-type: "image/jpeg", "image/png", albo "image/gif”’ \
-H ‘accept-language: pl-PL’, (albo en-EN) \
--data-binary "@file_to_upload.png" -- wymagane, zawartość pliku z
obrazkiem w postaci binarnej
'https://upload.allegro.pl/sale/images
-H 'authorization: Bearer {token}' \
-H 'accept: application/vnd.allegro.beta.v1+json’ \
-H 'content-type: "image/jpeg", "image/png", albo "image/gif”’ \
-H ‘accept-language: pl-PL’, (albo en-EN) \
--data-binary "@file_to_upload.png" -- wymagane, zawartość pliku z
obrazkiem w postaci binarnej
Wiec dalem
Kod
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://upload.'.$dane['host_allegro'].'/sale/images');
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_HEADER, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'file' => '@obrazek.jpg',
));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$dane['token'].'',
'accept: application/vnd.allegro.beta.v1+json',
'content-type: "image/jpeg"',
'accept-language: pl-PL',
));
$postResult = curl_exec($ch);
curl_close($ch);
print_r($postResult);
curl_setopt($ch, CURLOPT_URL, 'https://upload.'.$dane['host_allegro'].'/sale/images');
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_HEADER, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'file' => '@obrazek.jpg',
));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$dane['token'].'',
'accept: application/vnd.allegro.beta.v1+json',
'content-type: "image/jpeg"',
'accept-language: pl-PL',
));
$postResult = curl_exec($ch);
curl_close($ch);
print_r($postResult);
Za kazdym razem jaka nie wpisze sciezke mam komunikat HTTP 415 Unsupported Media Type. Podejrzewam ze cos zle robie ale od godziny nie moge tego znalezc. Moze pole 'file' w POST powinno sie inaczej nazywac ? Moze podaje zla sciezke (plik ktory wywoluje i plik obrazka sa w tym samym folderze). Probowalem roznych obrazkow ale wszystko zwraca ten sam blad ...