Я написал запрос curl, чтобы получить ссылку для автоматизации. Но это возвращает 401.
Мне просто нужен список автоматизации по вызову GET.
Мне не понятно, что не так в моем коде. Я считаю, что керл-колл это хорошо.
Есть идеи?
// Here is the data we will be sending to the service
$some_data = array(
'apikey' => 'xxxxxxxxwqew3423xxxxx'
);
$curl = curl_init();
// You can also set the URL you want to communicate with by doing this:
// $curl = curl_init('http://localhost/echoservice');
// We POST the data
curl_setopt($curl, CURLOPT_POST, 1);
// Set the url path we want to call
curl_setopt($curl, CURLOPT_URL, 'https://us13.api.mailchimp.com/3.0/automations');
// Make it so the data coming back is put into a string
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Insert the data
curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
// You can also bunch the above commands into an array if you choose using: curl_setopt_array
// Send the request
$result = curl_exec($curl);
// Get some cURL session information back
$info = curl_getinfo($curl);
print_r($info);
echo 'content type: ' . $info['content_type'] . '<br />';
echo 'http code: ' . $info['http_code'] . '<br />';
// Free up the resources $curl is using
curl_close($curl);
echo $result;
Ответ:
http code: 401
{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"API Key Missing","status":401,"detail":"Your request did not include an API key.","instance":"xxxxx-xxxxxx-xxxxxxxx"}