Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending SMS through Twilio
Message
De
08/05/2015 12:53:50
 
 
À
08/05/2015 09:36:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01619544
Message ID:
01619554
Vues:
61
>Hi,
>
>I've been trying out an online service that allows you to send SMS. Unfortunately I am having difficulty understanding their samples and translating them to VFP.
>
>You can view their code samples for various languages here:
>
>https://www.twilio.com/docs/api/rest/sending-messages
>
>This is what their help desk sent to me:
>
>"But I can help you with making a POST call to send SMS from your application.
>
>You would need these:
>URL - You already have it
>Account Sid
>Auth token
>From, To and Body / MediaUrl as form parameters
>
>Check if that library does the following:
>
> Ability to set From, To, Body key value pairs in form rather than in the URL as query parameters. Also ensure that the library sets the Content-type to "application/x-www-form-urlencoded". If it doesn't please set the header manually.
>
> Ability to convert Account Sid & Auth token into a Base64 encoded value.
>
>If it doesn't, you may have to use any built-in / 3rd party VFP libraries to convert "Account Sid":"Auth token" combination to a Base64Encoded value.
>eg. if Account Sid = AC123434598475 & Auth Token = slak09j4g49j04j
>Base64Encode("AC123434598475:slak09j4g49j04j") - Do not forget the ':'
>Set this base64 Encoded value in "Authorization" header, but ensure you prefix the value with "Basic "
>So the header would look like,
>
>Authorization Basic < Base 64 encoded value >
>
>The header and form parameter, briefed above, is available in JSON example in the following article
>https://www.twilio.com/docs/api/rest/sending-messages"
>
>This is the code I was trying:
>
>
SET LIBRARY TO vfpconnection.fll ADDITIVE 
>
>*!*	SetConnectTimeout(oAppInfo.ConnectTimeOut) && Default is 10 seconds
>*!*	SetResponseTimeout(oAppInfo.ResponseTimeOut) && Default is 10 seconds
>SetConnectTimeout(30) && Default is 10 seconds
>SetResponseTimeout(30) && Default is 10 seconds
>
>*!*	https://api.twilio.com/2010-04-01/Accounts/ACb832550f3d5e416b54a3ff1c0c7d08b1/Messages.json \
>*!*	    -d "Body=Jenny%20please%3F%21%20I%20love%20you%20<3" \
>*!*	    -d "To=%2B15558675309" \
>*!*	    -d "From=%2B14158141829" \
>*!*	    -d "MediaUrl=http://www.example.com/hearts.png" \
>*!*	    -u 'ACb832550f3d5e416b54a3ff1c0c7d08b1:{AuthToken}'
>    
>m.lcURL = "https://api.twilio.com/2010-04-01/Accounts/ACb832550f3d5e416b54a3ff1c0c7d08b1/Messages.json"
>
>LOCAL ARRAY laPost[3,2]
>laPost[1,1] = "Body"
>laPost[1,2] = "Test Message from Frank via Twilio"
>laPost[2,1] = "To" && name
>laPost[2,2] = "+18689999999"
>laPost[3,1] = "From" && name
>laPost[3,2] = "+18688888888"
>
>IF NOT HttpPost(m.lcURL, @laPost, "", "APITrace()")
>	MESSAGEBOX("An error occurred sending the SMS: " + m.cTraceData, 16, "Send SMS Via Twilio")
>ENDIF
>
>
>Can anyone help me get this clear in my head?

Pretty sure Steve Bodnar presented about Twilio at Southwest Fox in the last few years. I don't know whether he made his paper public, but that might be a place to start.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform