Domanda

The API states that status_callback is: "A URL that Twilio will request when the call ends to notify your app."

Okay, so....does this url execute TwiML or no?

I'm really confused.

require 'twilio-ruby' 

account_sid = '##' 
auth_token = '##' 

@client = Twilio::REST::Client.new account_sid, auth_token 

@client.account.calls.create({ 
    :from => '+18005550199', 
    :to => '+10000000000',
    :url => 'http://thisurl.com/blahblah/outbound.xml',   #plays a message to :to
    :status_callback => "http://i don't know what to do here or if this url is supposed to execute TwiML"
})
È stato utile?

Soluzione

A request to make a phone call may take a "long" time (in terms of web requests that means "several seconds"). Therefore the API cannot answer with a single return code, but it will update your status after some "some time" using a post-back URL. Try providing a URL to your own app and see what comes back.

Trouble is in order to do this you will most probably need a deployed app as you need a publicly available URL to do so (and localhost will not do :-). So you will have to setup a test domain, but most probably you will be able to use a subdomain, something like beta.mydomain.comin order to figure out what you will get.

Most of the examples they show on their website seem to be in PHP, but the callbacks they provide after making a call seem to expect to be called after "some time" if a connection could be established.

The API-Link you provided states rather clearly

After a call ends, Twilio will make an asynchronous HTTP request to the StatusCallback URL if you provided one in your POST. This will happen regardless of the call status.

so that is what you should expect, an asynchronous HTTP request to the callback-link you provide. This is made asynchronously as Twillio can not maintain an http-connection for the (indefinite) duration of your call. So you should provide it with an URL such as

http://beta.mydomain.com/call-me-back-here

and wire it to an appropriate route (most probably a POST-request).

Altri suggerimenti

Seems like what is missing is a good explanation as to the purpose of the callback. Is it calling back and expecting to retrieve a URL for a webpage that it will forward to the requester? Or is it simply to notify your server that a request has completed and there is no reply necessary except for a 200.

Maybe provide this in a comment here: https://www.twilio.com/docs/video/api/rooms-resource#create-room

Some API providers expect a return. This explanation is missing in the documents leaving the developers guessing as to its purpose. E.G. Stripe expects a webpage that it returns to the enduser. Thx in advance.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top