PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 18, 2022

[FIXED] How to integrate audio call(User to User) using twilio API?

 November 18, 2022     twilio, twilio-api, twilio-click-to-call, twilio-php     No comments   

Issue

I want to integrate user to user audio call feature using Twilio API, is it possible in Twilio? if yes can you please provide a tutorial.

Here I have added the code:
1. For get token from the Twilio

$.post(url, function(data) {      
 // Set up the Twilio Client Device with the token
    Twilio.Device.setup(data.token);
});

and it returns the token using function

public function newToken(Request $request, ClientToken $clientToken)
    {
        $forPage = $request->input('forPage');
        $twilio = config('services.twilio');
        $applicationSid = $twilio['applicationSid'];
        $clientToken->allowClientOutgoing($applicationSid);

        if ($forPage === route('dashboard', [], false)) {
            $clientToken->allowClientIncoming('support_agent');
        } else {
            $clientToken->allowClientIncoming('customer');
        }

        $token = $clientToken->generateToken();
        return response()->json(['token' => $token]);
    }

When I make a call following javascript function start

function callCustomer(phoneNumber) {
    updateCallStatus("Calling " + phoneNumber + "...");

    var params = {"phoneNumber": phoneNumber};
    Twilio.Device.connect(params);
}

and then browser ask for the enable microphone and after allowing it plays the small audio say's that "Application error occurred, Good bye!".


Solution

Twilio voice call please refer the following documentation step by step QuickStartDemo



Answered By - user3952538
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing