Skip to content

Commit 2a58ed6

Browse files
authored
Merge pull request TwilioDevEd#269 from etsai/msg-services-api
update copilot examples for launch
2 parents fa62781 + 7a471dc commit 2a58ed6

27 files changed

+119
-69
lines changed

messaging/services/service-create/output/service-create.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3-
"friendly_name": "My Service!",
43
"sid": "MG2172dd2db502e20dd981ef0d67850e1a",
54
"date_created": "2017-03-14T20:12:31Z",
65
"date_updated": "2017-03-14T20:12:33Z",
@@ -9,7 +8,7 @@
98
"inbound_method": "POST",
109
"fallback_url": null,
1110
"fallback_method": "POST",
12-
"status_callback": "https://www.example.com",
11+
"status_callback": "http://requestb.in/1234abcd",
1312
"sticky_sender": true,
1413
"mms_converter": true,
1514
"links": {

messaging/services/service-create/service-create.5.x.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@
88
$auth_token = 'your_auth_token'
99
$twilio = new Twilio($account_sid, $auth_token);
1010

11-
$service = $twilio->messaging->v1->services->create("My Company");
11+
$service = $twilio->messaging->v1->services->create(
12+
"My First Service",
13+
array(
14+
'statusCallback' => "http://requestb.in/1234abcd"
15+
)
16+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
curl 'https://messaging.twilio.com/v1/Services' -X POST \
22
--data-urlencode 'FriendlyName=My First Service' \
3+
--data-urlencode 'StatusCallback=http://requestb.in/1234abcd' \
34
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token

messaging/services/service-get/output/service-get.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"inbound_method": "POST",
1010
"fallback_url": null,
1111
"fallback_method": "POST",
12-
"status_callback": "https://www.example.com",
12+
"status_callback": "http://requestb.in/1234abcd",
1313
"sticky_sender": true,
1414
"mms_converter": true,
1515
"links": {

messaging/services/service-list/output/service-list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"inbound_method": "POST",
2222
"fallback_url": null,
2323
"fallback_method": "POST",
24-
"status_callback": "https://www.example.com",
24+
"status_callback": "http://requestb.in/1234abcd",
2525
"links": {
2626
"phone_numbers": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers",
2727
"short_codes": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/ShortCodes",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
curl 'https://messaging.twilio.com/v1/Services' \
2-
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:[AuthToken]
2+
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"title": "Add multiple phone numbers to Messaging Services",
3+
"type": "server",
4+
"tags": ["messaging"]
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3+
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
4+
"sid": "PN2a0747eba6abf96b7e3c3ff0b4530f6e",
5+
"date_created": "2017-03-14T20:15:31Z",
6+
"date_updated": "2017-03-14T20:15:33Z",
7+
"phone_number": "+441632960556",
8+
"country_code": "GB",
9+
"capabilities": ["sms"],
10+
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e"
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
// Get the PHP helper library from twilio.com/docs/php/install
3+
require_once '/path/to/vendor/autoload.php'; // Loads the library
4+
5+
use Twilio\Rest\Client;
6+
7+
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
8+
$auth_token = 'your_auth_token'
9+
$twilio = new Twilio($account_sid, $auth_token);
10+
11+
$phoneNumbers = array("PN2a0747eba6abf96b7e3c3ff0b4530f6e", "PN557ce644e5ab84fa21cc21112e22c485", "PN2a0747eba6abf96b7e3c3ff0b4530f6e")
12+
13+
foreach ($phoneNumbers as $number) {
14+
$phoneNumber = $twilio->messaging->v1->services("MG2172dd2db502e20dd981ef0d67850e1a")
15+
->phoneNumber->create($number);
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
curl 'https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers' -X POST \
2+
--data-urlencode 'PhoneNumberSid=PN557ce644e5ab84fa21cc21112e22c485' \
3+
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"title": "Delete a Phone Number from a Messaging Service",
33
"type": "server",
4-
"description": "Delete a Phone Number from a Messaging Service",
54
"tags": ["messaging"]
65
}

messaging/services/service-number-list/output/service-number-list.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,20 @@
2626
"sid": "PN2a0747eba6abf96b7e3c3ff0b4530f6e",
2727
"date_created": "2017-03-14T20:15:31Z",
2828
"date_updated": "2017-03-14T20:15:33Z",
29-
"phone_number": "+987654321",
30-
"country_code": "US",
31-
"capabilities": ["sms", "mms"],
29+
"phone_number": "+441632960556",
30+
"country_code": "GB",
31+
"capabilities": ["sms"],
32+
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e"
33+
}
34+
{
35+
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
36+
"service_sid": "MG2172dd2db502e20dd981ef0d67850e1a",
37+
"sid": "PN2a0747eba6abf96b7e3c3ff0b4530f6e",
38+
"date_created": "2017-03-14T20:15:31Z",
39+
"date_updated": "2017-03-14T20:15:33Z",
40+
"phone_number": "+611900654321",
41+
"country_code": "AU",
42+
"capabilities": ["sms"],
3243
"url": "https://messaging.twilio.com/v1/Services/MG2172dd2db502e20dd981ef0d67850e1a/PhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e"
3344
}
3445
]

rest/messages/send-messages-copilot/output/out.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"date_updated": "Tue, 03 Nov 2015 20:26:16 +0000",
55
"date_sent": null,
66
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
7-
"to": "+16518675309",
7+
"to": "+441632960675",
88
"from": null,
99
"messaging_service_sid": "MG9752274e9e519418a7406176694466fa",
1010
"body": "Phantom Menace was clearly the best of the prequel trilogy.",

rest/messages/send-messages-copilot/output/out.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<DateUpdated>Tue, 03 Nov 2015 20:28:44 +0000</DateUpdated>
77
<DateSent/>
88
<AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
9-
<To>+16518675309</To>
9+
<To>+441632960675</To>
1010
<From/>
1111
<MessagingServiceSid>MG9752274e9e519418a7406176694466fa</MessagingServiceSid>
1212
<Body>Phantom Menace was clearly the best of the prequel trilogy.</Body>

rest/messages/send-messages-copilot/send-messages-copilot.2.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var client = require('twilio')(accountSid, authToken);
66

77
client.sendMessage({
88
messagingServiceSid: 'MG9752274e9e519418a7406176694466fa',
9-
to: '+16518675309',
9+
to: '+441632960675',
1010
body: 'Phantom Menace was clearly the best of the prequel trilogy.'
1111
}, function(err, message) {
1212
console.log(message);

rest/messages/send-messages-copilot/send-messages-copilot.3.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const client = require('twilio')(accountSid, authToken);
77
client.messages
88
.create({
99
messagingServiceSid: 'MG9752274e9e519418a7406176694466fa',
10-
to: '+16518675309',
10+
to: '+441632960675',
1111
body: 'Phantom Menace was clearly the best of the prequel trilogy.',
1212
})
1313
.then((message) => console.log(message));
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
// Download the twilio-csharp library from twilio.com/docs/csharp/install
2-
using System;
3-
using Twilio;
4-
class Example
5-
{
6-
static void Main(string[] args)
7-
{
8-
// Find your Account Sid and Auth Token at twilio.com/user/account
9-
string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
10-
string AuthToken = "[AuthToken]";
11-
var twilio = new TwilioRestClient(AccountSid, AuthToken);
12-
1+
// Download the twilio-csharp library from twilio.com/docs/csharp/install
2+
using System;
3+
using Twilio;
4+
class Example
5+
{
6+
static void Main(string[] args)
7+
{
8+
// Find your Account Sid and Auth Token at twilio.com/user/account
9+
string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
10+
string AuthToken = "[AuthToken]";
11+
var twilio = new TwilioRestClient(AccountSid, AuthToken);
12+
1313
var message = twilio.SendMessageWithService(
14-
"MG9752274e9e519418a7406176694466fa", "+16518675309",
14+
"MG9752274e9e519418a7406176694466fa", "+441632960675",
1515
"Phantom Menace was clearly the best of the prequel trilogy."
16-
);
17-
Console.WriteLine(message.Sid);
18-
}
16+
);
17+
Console.WriteLine(message.Sid);
18+
}
1919
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22

3-
// this line loads the library
4-
require('/path/to/twilio-php/Services/Twilio.php');
5-
3+
// this line loads the library
4+
require('/path/to/twilio-php/Services/Twilio.php');
5+
66
// Download the PHP helper library from twilio.com/docs/php/install
77
// These vars are your accountSid and authToken from twilio.com/user/account
8-
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
9-
$auth_token = 'your_auth_token';
10-
$client = new Services_Twilio($account_sid, $auth_token);
11-
12-
$client->account->messages->create(array(
13-
'To' => "+15558675309",
14-
'MessagingServiceSid' => "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
8+
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
9+
$auth_token = 'your_auth_token';
10+
$client = new Services_Twilio($account_sid, $auth_token);
11+
12+
$client->account->messages->create(array(
13+
'To' => "+441632960675",
14+
'MessagingServiceSid' => "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1515
'Body' => "Phantom Menace was clearly the best of the prequel trilogy.",
1616
));
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
require 'rubygems' # not necessary with ruby 1.9 but included for completeness
2-
require 'twilio-ruby'
3-
4-
# put your own credentials here
5-
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
6-
auth_token = '[AuthToken]'
7-
8-
# set up a client to talk to the Twilio REST API
9-
@client = Twilio::REST::Client.new account_sid, auth_token
10-
1+
require 'rubygems' # not necessary with ruby 1.9 but included for completeness
2+
require 'twilio-ruby'
3+
4+
# put your own credentials here
5+
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
6+
auth_token = '[AuthToken]'
7+
8+
# set up a client to talk to the Twilio REST API
9+
@client = Twilio::REST::Client.new account_sid, auth_token
10+
1111
@client.account.messages.create({
12-
:messaging_service_sid => 'MG9752274e9e519418a7406176694466fa',
13-
:to => '+16518675309',
12+
:messaging_service_sid => 'MG9752274e9e519418a7406176694466fa',
13+
:to => '+441632960675',
1414
:body => 'Phantom Menace was clearly the best of the prequel trilogy.'
1515
})

rest/messages/send-messages-copilot/send-messages-copilot.5.x.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static void Main(string[] args)
1313
const string authToken = "[AuthToken]";
1414
TwilioClient.Init(accountSid, authToken);
1515

16-
var to = new PhoneNumber("+16518675309");
16+
var to = new PhoneNumber("+441632960675");
1717
var message = MessageResource.Create(
1818
to,
1919
messagingServiceSid: "MG9752274e9e519418a7406176694466fa",

rest/messages/send-messages-copilot/send-messages-copilot.5.x.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$client = new Client($account_sid, $auth_token);
1111

1212
$client->messages->create(
13-
"+15558675309",
13+
"+441632960675",
1414
array(
1515
'messagingServiceSid' => "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1616
'body' => "Phantom Menace was clearly the best of the prequel trilogy."
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from twilio.rest import TwilioRestClient
2-
3-
# put your own credentials here
4-
ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
5-
AUTH_TOKEN = "[AuthToken]"
6-
7-
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
8-
1+
from twilio.rest import TwilioRestClient
2+
3+
# put your own credentials here
4+
ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
5+
AUTH_TOKEN = "[AuthToken]"
6+
7+
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
8+
99
client.messages.create(
10-
to="+16518675309",
11-
messaging_service_sid="MG9752274e9e519418a7406176694466fa",
10+
to="+441632960675",
11+
messaging_service_sid="MG9752274e9e519418a7406176694466fa",
1212
body="Phantom Menace was clearly the best of the prequel trilogy.",
1313
)

rest/messages/send-messages-copilot/send-messages-copilot.5.x.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
@client.account.messages.create(
1212
messaging_service_sid: 'MG9752274e9e519418a7406176694466fa',
13-
to: '+16518675309',
13+
to: '+441632960675',
1414
body: 'Phantom Menace was clearly the best of the prequel trilogy.'
1515
)

rest/messages/send-messages-copilot/send-messages-copilot.6.x.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void main(String[]args) throws TwilioRestException {
1919

2020
// Build the parameters
2121
List<NameValuePair> params = new ArrayList<NameValuePair>();
22-
params.add(new BasicNameValuePair("To", "+16518675309"));
22+
params.add(new BasicNameValuePair("To", "+441632960675"));
2323
params.add(new BasicNameValuePair("MessagingServiceSid", "MG9752274e9e519418a7406176694466fa"));
2424
params.add(new BasicNameValuePair("Body",
2525
"Phantom Menace was clearly the best of the prequel trilogy."));

rest/messages/send-messages-copilot/send-messages-copilot.6.x.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
client = Client(account_sid, auth_token)
88

99
client.messages.create(
10-
to="+16518675309",
10+
to="+441632960675",
1111
messaging_service_sid="MG9752274e9e519418a7406176694466fa",
1212
body="Phantom Menace was clearly the best of the prequel trilogy.")

rest/messages/send-messages-copilot/send-messages-copilot.7.x.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static void main(String[] args) {
1212
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
1313

1414
Message message =
15-
Message.creator(new PhoneNumber("+16518675309"), "MG9752274e9e519418a7406176694466fa",
15+
Message.creator(new PhoneNumber("+441632960675"), "MG9752274e9e519418a7406176694466fa",
1616
"Phantom Menace was clearly the best of the prequel trilogy.").create();
1717

1818
System.out.println(message.getSid());
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json' \
2-
--data-urlencode 'To=+16518675309' \
2+
--data-urlencode 'To=+441632960675' \
33
--data-urlencode 'MessagingServiceSid=MG9752274e9e519418a7406176694466fa' \
44
--data-urlencode 'Body=Phantom Menace was clearly the best of the prequel trilogy.' \
55
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:auth_token

0 commit comments

Comments
 (0)