Python'da eroku üzerinde TwiMl kurulumu var. Kullanıcı B'den B kullanıcısını aradığımda, A kullanıcısı arama ve VOIP de almadı; B kullanıcısı ise "aradığınız için teşekkürler" gibi bir bot mesajına sahip.twilio Uygulamaya sesli arama Uygulama çalışmıyor
kullanıcı B'ye PostMan
'dan denediğimde, B kullanıcısı çağrı alır ve "aradığınız için teşekkürler" gibi bir bot mesajı alır.
PostMan URL: Ben buna alacak uygulama kullanıcı B'den kullanıcı A arayıp hem edebilmek iletişim kurabilir zaman https://myapp.herokuapp.com/placeCall
Benim gerekliliktir.
Gereği
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
Werkzeug==0.9.6
httplib2==0.9
itsdangerous==0.24
six==1.*
twilio
wsgiref==0.1.2
İşte benim Python TwiMl Kod olduğunu.
import os
from flask import Flask, request
from twilio.jwt.access_token import AccessToken
from twilio.jwt.access_token.grants import VoiceGrant
from twilio.rest import Client
import twilio.twiml
ACCOUNT_SID = 'ACxxxxxxxx'
API_KEY = 'SKxxxxxxxx'
API_KEY_SECRET = 'TSxxxxxxxx'
PUSH_CREDENTIAL_SID = 'CRxxxxxxxx'
APP_SID = 'APxxxxxxxx'
app = Flask(__name__)
@app.route('/test', methods=['GET', 'POST'])
def test():
req_json = request.get_json(force=True)
UserName = req_json['username']
Password = req_json['password']
return str(UserName)
@app.route('/accessToken')
def token():
IDENTITY = request.args.get('identity')
account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
api_key = os.environ.get("API_KEY", API_KEY)
api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)
push_credential_sid = os.environ.get("PUSH_CREDENTIAL_SID", PUSH_CREDENTIAL_SID)
app_sid = os.environ.get("APP_SID", APP_SID)
grant = VoiceGrant(push_credential_sid=push_credential_sid,outgoing_application_sid=app_sid)
token = AccessToken(account_sid, api_key, api_key_secret, IDENTITY)
token.add_grant(grant)
return str(token)
@app.route('/outgoing', methods=['GET', 'POST'])
def outgoing():
req_json = request.get_json(force=True)
CALLER_ID = req_json['callerid']
resp = twilio.twiml.VoiceResponse()
dial = Dial()
dial.client(CALLER_ID)
resp.append(dial)
#resp.say("Congratulations! You have made your first oubound call! Good bye.")
#resp.say("Thanks for Calling.",voice='woman',)
return str(resp)
@app.route('/incoming', methods=['GET', 'POST'])
def incoming():
resp = twilio.twiml.VoiceResponse()
#resp.say("Congratulations! You have received your first inbound call! Good bye.")
#resp.say("Thanks for Calling.",voice='woman',)
return str(resp)
@app.route('/placeCall', methods=['GET', 'POST'])
def placeCall():
req_json = request.get_json(force=True)
IDENTITY = req_json['identity']
CALLER_ID = req_json['callerid']
account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
api_key = os.environ.get("API_KEY", API_KEY)
api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)
client = Client(api_key, api_key_secret, account_sid)
call = client.calls.create(url=request.url_root + 'incoming', to='client:' + CALLER_ID, from_='client:' + IDENTITY)
return str(call.sid)
@app.route('/', methods=['GET', 'POST'])
def welcome():
resp = twilio.twiml.VoiceResponse()
resp.say("Welcome")
return str(resp)
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port, debug=True)
Hata Kayıtlar Twilio gösterge tablosunda ayarı
TwiML
URL isteği: https://myapp.herokuapp.com/outgoing
lütfen haber verin ben yapılandırmak cevapsız bir şey var mı ya yanlış yaptığım bir şey. Ben TwiML yapılandırmak için takip
Eğitimi Here
Yanıtın için teşekkürler, güncel soru ve hata günlüklerimi kontrol edermisiniz, bu gerçekten sorunu çözmemde bana yardımcı olur – PinkeshGjr
Bu yeni bir hatadır, yani normalde bunun için yeni bir soru açmak en iyisidir. Bu durumda, sorun 'VoiceGrant'ı yanlış yerden alıyorsunuz. Twilio.jwt.access_token.grants öğesinden VoiceGrant öğesini içe aktarmanız gerekiyor. [Erişim belirteci belgelerini] kontrol edin (https://www.twilio.com/docs/api/rest/access-tokens?code-sample=code-creating-an-access-token-voice&code-language=py&code-sdk- Daha fazla detay için versiyon = 6.x). – philnash
başka bir hata aldım lütfen hata kayıtlarıyla birlikte teşekkürler güncelleştirilmiş soru ile kontrol edin. – PinkeshGjr