2016-04-30 20 views
0

私はtwilioクイックスタートを通過していますが、問題があります。私の呼び出しボタンはtwilioのリクエストをトリガしません。ここで Twilioブラウザからブラウザ

namespace twilioMvc.Controllers 
{ 
    public class BrowserToBrowserController : Controller 
    { 
     string accountSid; 
     string authToken; 
     string appSid; 
     string clientName; 
     string token; 
     public BrowserToBrowserController() 
     { 
      NameValueCollection manager = ConfigurationManager.GetSection("appSettings") as NameValueCollection; 
      accountSid = manager["acSID"]; 
      authToken = manager["authToken"]; 
      // put your Twilio Application Sid here 
      appSid = manager["appSID"]; 
      // put your default Twilio Client name here 
      clientName = "jenny"; 

      var capability = new TwilioCapability(accountSid, authToken); 
      capability.AllowClientOutgoing(appSid); 
      capability.AllowClientIncoming(clientName); 
      token = capability.GenerateToken(); 
     } 

     public ActionResult Index(string name) 
     { 
      if (name != "" && name != null) 
      { 
       clientName = name; 
      } 

      var client = new Client() { clientName = clientName, token = token }; 
      return View("Index", client); 
     } 

     [HttpPost] 
     public ActionResult Call(string PhoneNumber) 
     { 
      // put your default Twilio Client name here, for when a phone number isn't given 
      string number = "jenny"; 

      // get the phone number from the page request parameters, if given 
      if (PhoneNumber != null) 
      { 
       number = PhoneNumber; 
      } 

      var response = new XElement("Response"); 
      response.Add(new XElement("Dial", new XElement("Client", number)));        

      return this.Content(response.Value, "text/xml"); 

     } 
    } 
} 

@model twilioMvc.Models.Client 

<!DOCTYPE html> 
<html> 
<head> 
    <title>Hello Client Monkey 5</title> 
    <script type="text/javascript" 
      src="//media.twiliocdn.com/sdk/js/client/v1.3/twilio.min.js"></script> 
    <script type="text/javascript" 
      src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> 
    </script> 
    <link href="//static0.twilio.com/resources/quickstart/client.css" 
      type="text/css" rel="stylesheet" /> 
    <script type="text/javascript"> 

     Twilio.Device.setup('@Model.token'); 

     Twilio.Device.ready(function (device) { 
      $("#log").text("Client '@Model.clientName' is ready"); 
     }); 

     Twilio.Device.error(function (error) { 
      $("#log").text("Error: " + error.message); 
     }); 

     Twilio.Device.connect(function (conn) { 
      $("#log").text("Successfully established call"); 
     }); 

     Twilio.Device.disconnect(function (conn) { 
      $("#log").text("Call ended"); 
     }); 

     Twilio.Device.incoming(function (conn) { 
      $("#log").text("Incoming connection from " + conn.parameters.From); 
      // accept the incoming connection and start two-way audio 
      conn.accept(); 
     }); 

     function call() { 
      // get the phone number or client to connect the call to 
      params = { "PhoneNumber": $("#number").val() }; 
      Twilio.Device.connect(params); 
     } 

     function hangup() { 
      Twilio.Device.disconnectAll(); 
     } 
    </script> 
</head> 
<body> 
    <button class="call" onclick="call();"> 
     Call 
    </button> 

    <button class="hangup" onclick="hangup();"> 
     Hangup 
    </button> 

    <input type="text" id="number" name="number" 
      placeholder="Enter a phone number or client to call" /> 

    <div id="log">Loading pigeons...</div> 
</body> 
</html> 

だから、私は私の通話ボタンをクリックすると、そこにアプリをtwilioするために呼び出すべきであるし、それは私のapllicationセクションに満たされた空のルート(と、私のサイトを呼び出す必要がありますページのコードですon twilio site)しかし、問題があります。手伝っていただけませんか?

+0

'$("#number ")'の代わりに '$(" number ")'を使ってみてください。 – gmiley

+0

番号フィールドからのデータの取得に問題はありません。 –

+0

あなたはそれから得ているエラーは何ですか?デバッグをしましたか?コードはどこで失敗するのですか? – gmiley

答えて

0

Object.assignのブラウザpolyfillに追加する際にエラーを修正しました。 しかし、ブラウザからブラウザへの直接の呼び出しで別の問題が発生しました。

+0

これは正しいとは思わない! Twilioライブラリは、必要なすべてのメソッドを提供する必要があります。これをテストしているブラウザとエラーメッセージが表示された[email protected]にメールしてください。 – philnash