I am trying to learn how to use httr
to access an SMS service's API. The package documentation is helpful, but I think I lack an understanding of some important higher level concepts. Could someone point me to a good tutorial for using httr
?
In case it is helpful in directing me to the right type of resource, here is an example of a url I am trying to use from the service provider's API documentation (account is not active):
http://sms.shujaa.mobi/sendsms?username=info%40shujaa.co.ke&password=info&account=developer&source=2024&destination=254717555555&message=This%20is%20a%20test.&network=safaricom
My first inclination was to define each object and then paste together the string.
library(httr)
url <- "http://sms.shujaa.mobi/sendsms"
username <- "info%40shujaa.co.ke"
password <- "info&account"
account <- "developer"
source <- "2024"
destination <- "254717555555"
message <- "This%20is%20a%20test."
network <- "safaricom"
send <- paste0(url, "?", "username=", username, "&password=", password, "&account=",
account, "&source=", source, "&destination=", destination, "&message=", message,
"&network=", network)
POST(send)
I don't think this is the correct approach. I think I should be using some of the arguments of POST to modify the url with the necessary info, but I'm not seeing the bigger picture. I think an example or two might help me move in the right direction. The included demos don't seem to address my confusion.