neubert
neubert

Reputation: 16802

unable to send out voice broadcast with callfire REST API

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..

Upvotes: 1

Views: 461

Answers (2)

chrismec
chrismec

Reputation: 103

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

Upvotes: 1

John
John

Reputation: 36

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

Upvotes: 2

Related Questions