来自谁的twilio电话是谁?

时间:2016-07-06 11:07:46

标签: java rest web-applications twilio voip

对于通过API进行的此调用,如何将其与我在Twilio上存档的SIP URI连接?究竟,这个电话是“来自”的?

Call SID
    CA4759gfrjklg45jfgklj54klfsgjf0073a
Date
    10:55:04 UTC 2016-07-06
Start Time
    10:55:04 UTC 2016-07-06 
End Time
    10:55:19 UTC 2016-07-06 
Duration
    15 secs
Cost
    $0.015 

From
To
    (202) 456-1111 
Direction
    Outgoing API
Secure Trunking
    Disabled
Status
    Completed

我很欣赏传出电话有效的录音信息,但如果他们不这样做会怎么样?我想我只需要花钱来全面测试出站功能吗?

1 个答案:

答案 0 :(得分:0)

如果您确实通过REST API making SIP calls,则To参数是您要连接的SIP URI,From是用于填充用户名部分的值传递给SIP端点的From标头。这可以是任何字母数字字符,以及加号,减号,下划线和句点字符(+ -_。)。不允许使用空格或其他字符。

在Java中创建基本SIP拨号的示例:

// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.factory.CallFactory;
import com.twilio.sdk.resource.instance.Call;
import com.twilio.sdk.resource.list.CallList;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the CallList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("Url", "http://www.example.com/sipdial.xml"));
    params.add(new BasicNameValuePair("To", "sip:kate@example.com"));
    params.add(new BasicNameValuePair("From", "Jack"));


    CallFactory callFactory = client.getAccount().getCallFactory();
    Call call = callFactory.create(params);
    System.out.println(call.getSid());
  }
}

不确定您在这里遇到了什么麻烦,但如果需要,我很乐意提供更多帮助。