1

I'm trying to send out an outbound call with the callfire REST API and am having some difficulty doing so. Here's my code (adapted from https://developers.callfire.com/docs.html#createVoiceBroadcast):

<?php
$username = '...';
$password = '...';

$data = array(
    'name' => 'Automation Test',
    'fromNumber' => '...',
    'recipients' => array(
        array('phoneNumber' => '...')
    ),
    'answeringMachineConfig' => 'AM_AND_ALIVE',
    'liveSoundText' => 'hello, world!',
    'machineSoundText' => 'hello, world!'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://api.callfire.com/v2/campaigns/voice-broadcasts');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$result = json_decode(curl_exec($ch));

print_r($result);

The problem is in the response. It's as follows:

stdClass Object
(
    [httpStatusCode] => 415
    [internalCode] => 0
    [message] => Exception in API
)

The 415 status code is for "Unsupported Media Type" per https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error but since I'm not uploading any media that error doesn't really make a lot of sense.

Maybe my value for answeringMachineConfig is invalid. idk what AM_AND_LIVE is supposed to mean but it's in the example so I'm using it. If there's only a small number of possible values the documentation should say so..

neubert
  • 15,947
  • 24
  • 120
  • 212

2 Answers2

2

You need to set content type to 'application/json'.

John
  • 36
  • 1
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). - [From Review](/review/low-quality-posts/10711874) – mjp66 Dec 29 '15 at 06:43
  • @mjp66 - I actually think it might. But I won't be able to test it out until Wednesday morning.. – neubert Dec 29 '15 at 07:14
1

Old I know, but just ran across it. Perhaps:

'answeringMachineConfig' => 'AM_AND_ALIVE',

should be:

'answeringMachineConfig' => 'AM_AND_LIVE',

You wrote ALIVE instead of LIVE

chrismec
  • 123
  • 5