Dream to Learn is shutting down...

We are very sorry to say that Dream to Learn will be shutting down as of December 28th, 2019. If you have content that you wish to keep, you should make a copy of it before that date.


1COMMENTS0RECOMMENDS

USING TWILIO API WITH R PROGRAMMING LANGUAGE & HTTR library (Twilio with R Part 2)

77
POSTED IN: Data Analytics & Visualization Blog

Greetings! In blog below I tried to use postForm from rCurl package - with mixed results.

Use HTTR Library and "POST" Instead

#works! and handles response well (post is httr)

library(httr)

the_url <- "https://ACda5eedceab2a9aae6472320bdc5XXXX:96ea43a811585a0f959675d1f95XXXXX@api.twilio.com/2010-04-01/Accounts/ACda5eedceab2a9aae6472320bdcXXXX/Messages.XML"

## SID:Token above 

POST(the_url, 
    body = list(
                From = "+1240837XXXX", 
                To = "+141567XXXXX",
                Body = "TWILIO TEST using R PROGRAMMING LANGUAGE - rCurl #12 - WOW, this sure works better using the library(httr) rather than rCurl.  Handles messages well"
    )
)

 

Response looks like this:

Response [https://ACda5eedceab2a9aae6472320bdcXXXX:96ea43a811585a0f959675d1f951XXXX@api.twilio.com/2010-04-01/Accounts/ACda5eedceab2a9aae6472320bdc5XXXX/Messages.XML]
  Status: 201
  Content-type: application/xml
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse><Message><Sid>SMe931965a83234f37b3ed9a56b23XXXX</Sid><DateCreated>Tue, 16 Dec 2014 06:21:53 +0000</DateCreated><DateUpdated>Tue, 16 Dec 2014 06:21:53 +0000</DateUpdated><DateSent/><AccountSid>ACda5eedceab2a9aae6472320bdc5XXXXX</AccountSid><To>+141567XXXXX</To><From>+124083XXXXX</From><Body>TWILIO TEST using R PROGRAMMING LANGUAGE - rCurl #12 - WOW, this sure works better using the library(httr) rather than rCurl.  Handles messages well</Body><Status>queued</Status><NumSegments>1</NumSegments><NumMedia>0</NumMedia><Direction>outbound-api</Direction><ApiVersion>2010-04-01</ApiVersion><Price/><PriceUnit>USD</PriceUnit><ErrorCode/><ErrorMessage/><Uri>/2010-04-01/Accounts/ACda5eedceab2a9aae6472320bdc54XXXX/Messages/SMe931965a83234f37b3ed9a56b23XXXX.XML</Uri><SubresourceUris><Media>/2010-04-01/Accounts/ACda5eedceab2a9aae6472320bdc5XXXX/Messages/SMe931965a83234f37b3ed9a56b23XXXX/Media.XML</Media></SubresourceUris></Message></TwilioResponse> 

 

Interested in more content by this author?

About the Author

Ryan Anderson

Ryan Anderson

Hi! I like to play with data, analytics and hack around with robots and gadgets in my garage. Lately I've been learning about machine learning.

About this blog

Description is...<br/>Data Analytics & Visualization Blog - Generating insights from Data since 2013

Created: July 25, 2014

Englishfrançais

Up Next