iron-io / iron_mq_php

PHP client for IronMQ.
www.iron.io
BSD 2-Clause "Simplified" License
89 stars 43 forks source link

Specify Content-Type Header for Curl request with postMessage #80

Open buttflattery opened 6 years ago

buttflattery commented 6 years ago

i could not find any source of setting the Content-Type headers for the curl call against the postMessage() function, previously i used to post messages using native curl like below with json data for curl POSTFIELDS option

$data = array(
            'messages' => array(
                array(
                    'body' => array(
                        'lead'=>1245121542124
                    ),
                    'delay' => intval($delay),
                ),
            ),
 );

$url = 'https://mq-kv-aws-us-east-1-1.iron.io/3/projects/' . $projectKey . '/queues/' . $queue . '/messages';
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'Authorization: OAuth ' . $this->token,
                'Content-Length: ' . strlen($data))
            );

            $result = curl_exec($ch);

            curl_close($ch);

But i couldnt find any option to specify the Content-Type : application/json when sending data to the postMessage