Answer the question
In order to leave comments, you need to log in
How to send a csv file to the Yandex Audience API?
Tell me how to send a file to Yandex.audience. curl.
After reviewing the Yandex documentation, here is the link https://yandex.ru/dev/audience/doc/segments/upload...
To be honest, I mainly used GET (When is the link and ? and & with info, you know) API requests (file_get_content), and curl isn't there yet.
I see this in the documentation
POST api-audience.yandex.ru/v1/management/segments/uplo...
Content-Type: multipart/form-data; boundary=------------------------5b2a52c5c90f668a
Context-Length: 331
Where to enter OAuth here...
If it's not difficult, give a hint, please.
I'll go while I try to gouge myself by studying the CURL documentation.
Answer the question
In order to leave comments, you need to log in
$filename = 'ox2.csv';
$ch = curl_init(' https://api-audience.yandex.ru/v1/management/segme... ');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: OAuth KEY HERE']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
$args['file'] = new CurlFile($filename, 'text/csv');
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$curl_response = curl_exec($ch);
var_dump($curl_response);
$res = curl_exec($ch);
print_r($res);
curl_close($ch);
Figured it out myself.
If it's not difficult, give a hint, please.Or learn web technologies (networking, data types, headers), or order freelance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question