plivo / plivo-php

Plivo PHP Helper Library
http://www.plivo.com
MIT License
110 stars 117 forks source link

startRecording method of class CallInterface is not handling the response when callback_url and callback_method is added to the parameter. #204

Closed ashishoxo closed 3 years ago

ashishoxo commented 3 years ago

Hi,

I am using this SDK in my project. When I am using the startRecording method as shown below.

$response = $client->calls->startRecording( $request->call_uuid,[ "callback_url" => "<SOME CALLBACK URL>", "callback_method" => "POST", ] );

Then I got an error. (Undefined index: url {"userId":2,"exception":"[object] (ErrorException(code: 0): Undefined index: url at vendor/plivo/plivo-php/src/Plivo/Resources/Call/CallInterface.php:463)

Please fix this issue in this SDK or let me know the better way to handle this.

Thanks

huzaif-plivo commented 3 years ago

@ashishoxo The issue here seems to be with the variable names declared in your code snippet. Plivo follows the camelCase naming convention for PHP. The ultimate code snippet is as follows: `<?php /**

try { $response = $client->calls->startRecording( '144481c2-09b3-4b82-b12a-ab3af5f68501', ["callbackUrl" => "", "callbackMethod" => "POST"] ); print_r($response); } catch (PlivoRestException $ex) { print_r($ex); }` In case of any queries, please feel free to reach out to our support team.

harikt commented 2 years ago

The answe provided by @huzaif-plivo is not correct.

If we change to use camel case it will not throw exception. But the callback is not triggered.

The main issue here is it is not properly handled in code level.

https://github.com/plivo/plivo-php/blob/4e30af7559687d3a07ebed1aa5fc72ff13ceeb55/src/Plivo/Resources/Call/CallInterface.php#L461

The response when we use callback_url is as

{"api_id":"xxx","message":"async api spawned"}

If we look into the phpdoc or api docs https://www.plivo.com/docs/voice/api/call/record-calls#start-recording-a-call there is no mention of camelCase .