简体   繁体   中英

How to transfer a call using the PHP-SDK v2 API

I've been in communication with the CallFire developers via email and really appreciate the help. I have a question about a send call method from the example from the generated PHP-SDK v2 examples.php Just to clarify I'm trying to accomplish, from a website I need to call a user, play a message, and then transfer to another number I will provide.

After searching the API documentation the word transfer occurs between 16 & 18 times for each SDK, but most of them are hidden, or have to do with Lease Configuration. The other example I have found is contained in a XML transfer guide : https://answers.callfire.com/hc/en-us/articles/200769678-Transfer . I know I can do this all in the PHP API but I need a little guidance.

In the PHP examples, liveMessageSoundid has 3 parameters in its json field, the integer is for the CallFire web backend but with machineMessage value it opens up a can of worms to follow, then machineMessageSoundId references transferMessage. Transfering a call is what I need but transferNumber has values string/voice/string. One of those strings must be the phone number but the SendCall method example never explicitly shows the transfer call command does it?

This is the example I'm working from which is building the json to transfer to CallFire.

   $request->getOperationConfig()->setBodyParameter("[phoneNumber" : "string",fromNumber" : "string",
                                                          "contactId" : integer,attributes" : [ "string" ],
                                                          "dialplanXml" : "string",liveMessage" : "string",
                                                          "liveMessageSoundId" : integer,machineMessage" : "string",
                                                          "machineMessageSoundId" : integer,transferMessage" : "string",
                                                          "transferMessageSoundId" : integer,transferDigit" : "string",
                                                          "transferNumber" : "string",voice" : "string"
                                                       }
                                                     ]");

This is what I have so far:

<?php

//These will be loaded from our site.
$number = "";
$name = "";
$rep_name = "";
$rep_number = "";

$live_message = "Hello," +$name+ " , Thank you for contacing Texas Home School Coalition, please stand by for a moment while we connect you to your representative.  Please have your statement ready regarding this important issue, we also left you a guide to read from on the action page you contacted us from":
$machine_message = "Hello, "+ $name +" , We received a request to give you a call from Texas Home School Coalition regarding an important issue for home schoolers and parents but we need you on the line in order to help you reach your representative.";

public static function main() {
    $client = \CallFire\Api\DocumentedClient::createClient("9dccec3d4ebb", "$PASSWORD");
    $request = $client->sendCalls();
    $request->getOperationConfig()->setHeaderParameters(array("Content-Type" => "application/json"));
    $body = '[
                {
            "defaultVoice" => "MALE1"
            "phoneNumber": "test_number",
            "fromNumber": "8067444441",
            "liveMessage": $live_message,
            "machineMessage": $machine_message,
            "transferMessage": $transfer_message,
            "transferNumber": $rep_number;
                }
             ]';
    $request->getOperationConfig()->setBodyParameter($body);
    $result = $client->request($request);
    $json = json_decode($result->getBody());
}

?>

as i mentioned in email - you code is correct, you just need to add one more param transferDigit to tell the system when to perform transfer.

These are all available params:

$request->getOperationConfig()->setBodyParameter("[
{
"phoneNumber" : "string",
"contactId" : integer,
"attributes" : [ "string" ],
"dialplanXml" : "string",
"liveMessage" : "string",
"liveMessageSoundId" : integer,
"machineMessage" : "string",
"machineMessageSoundId" : integer,
"transferMessage" : "string",
"transferMessageSoundId" : integer,
"transferDigit" : "string",
"transferNumber" : "string",
"voice" : "string"
}

So your body have to be like:

 {
                "defaultVoice" => "MALE1"
            "phoneNumber": "test_number",
            "fromNumber": "8067444441",
            "liveMessage": $live_message,
            "machineMessage": $machine_message,
            "transferMessage": $transfer_message,
            "transferNumber": $rep_number,
            "transferDigit" : "1 or 2 ....";
} 

Please also regenerate code samples, i don't know where you found example with things like: "liveMessageSoundId" : integer,machineMessage". Please see correct one

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM