Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending SMS through Twilio
Message
 
À
08/05/2015 14:06:13
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:
01619577
Vues:
47
>Thanks, where can I download wwHttp?

It's part of West Wind Client Tools:

http://west-wind.com/WestwindClientTools.aspx

It's not free though :-)

You can probably do what you need with vfpConnection too. The main point is that you have to post a JSON or XML document.

+++ Rick ---


>
>>Looking at the docs it seems you need to post a JSON or XML document not POST variables.
>>
>>Something like this (with wwHttp):
>>
>>
>>TEXT TO lcJson
>>{
>>   "account_sid": "AC5ef8732a3c49700934481addd5ce1659",
>>   "api_version": "2010-04-01",
>>   "body": "Jenny please?! I love you <3",
>>   "num_segments": "1",
>>   "num_media": "1",
>>   "date_created": "Wed, 18 Aug 2010 20:01:40 +0000",
>>   "date_sent": null,
>>   "date_updated": "Wed, 18 Aug 2010 20:01:40 +0000",
>>   "direction": "outbound-api",
>>   "error_code": null,
>>   "error_message": null,
>>   "from": "+14158141829",
>>   "price": null,
>>   "sid": "MM90c6fc909d8504d45ecdb3a3d5b3556e",
>>   "status": "queued",
>>   "to": "+15558675309",
>>   "uri": "/2010-04-01/Accounts/AC5ef8732a3c49700934481addd5ce1659/Messages/MM90c6fc909d8504d45ecdb3a3d5b3556e.json"
>>}
>>ENDTEXT
>>
>>DO wwHttp
>>loHttp = CREATEOBJECT("wwHttp")
>>loHttp.AppPostKey(lcJson)
>>loHttp.cContentType = "application/json"
>>
>>lcResponse = loHttp.HttpGet("https://api.twilio.com/2010-04-01/Accounts/AC5ef8732a3c49700934481addd5ce1659/Messages.json")
>>
>>
>>+++ Rick ---
>>
>>
>>>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?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform