Answered by:
Send a SMS via a link by clicking a button on a form

Question
-
When the operator issue an invoice or Order for a customer in my application I want to send him/her a confirmation SMS. Some SMS providers provide a link for this work like this:
http://www.behinpay.com/APISend.aspx?Username=$UserName&Password=$password&From=$FromNumber&To=$ToNumber&Text=$Text
I should fill the red items in this link:
Username: That is my user name in the SMS provider panel.
Password: That is my password in the SMS provider panel.
From: That is the unique number that we bought from this provider like 5000900 that is the number that SMS is sent from it.
To: The recipient number.
Text: The text that should be sent.
I want that when the operator click a button, I collect all information from database and create a link as above mentioned format, but I don't know how I can send this link for the SMS provider company or activate it.
Karim Vaziri Regards,
Friday, January 13, 2017 4:37 PM
Answers
-
Hi Karim,
Yes. The next approach is to try and use the HttpRequest Class so you don't see any browser window open.
Let us know how it goes...
- Marked as answer by kvaziri Sunday, January 15, 2017 7:05 PM
Friday, January 13, 2017 6:05 PM
All replies
-
Hi Karim,
There are a lot of ways to send the link. The simplest approach is to try the FollowHyperlink method first. For example:
Application.FollowHyperlink strURL
Hope it helps...
Friday, January 13, 2017 5:02 PM -
Dear DBguy,
It is very good but I don't want that the button opens a browser. I want that the SMS be sent after clicking the button and the user doesn't see any browser, because if I want to send for example 10 SMS simultaneously, it should open 10 browser or tabs. Is there any way that no browser opens.
Karim Vaziri Regards,
- Edited by kvaziri Friday, January 13, 2017 6:18 PM
Friday, January 13, 2017 5:50 PM -
Hi Karim,
Yes. The next approach is to try and use the HttpRequest Class so you don't see any browser window open.
Let us know how it goes...
- Marked as answer by kvaziri Sunday, January 15, 2017 7:05 PM
Friday, January 13, 2017 6:05 PM -
Dear DBguy,
Thank you very much. I sent SMS via HttpRequset class but unfortunately the SMS is in machine (strange characters) language. The SMS text is in Persian/Farsi language and when I send it, it is unreadable in recipient phone.
Karim Vaziri Regards,
Saturday, January 14, 2017 12:49 PM -
Hi Karim,
Sounds like before you execute the .Send method, you'll need to assign the correct character set in the header. For example:
xhr.open "GET", thisRequest, False
xhr.setRequestHeader = "accept-charset","UTF-8"
xhr.sendHope it helps...
Saturday, January 14, 2017 4:10 PM -
Dear Dbguy,
Unfortunately, it didn't solve the problem and the SMS is in strange characters.
The SMS provider company said you should use URL Encoder that you can send Farsi or Arabic SMS!
Karim Vaziri Regards,
- Edited by kvaziri Saturday, January 14, 2017 10:26 PM
Saturday, January 14, 2017 10:25 PM -
Oh, I see what you're saying. Because of this part in the URL:
...&Text=$Text
Yes, they're correct, you'll have to convert your message into a URL safe format. For example, a space character becomes %20 when URL encoded.
So, looks like you'll need to add a function to your application for converting the message to a URL encoded text.
Good luck!
Sunday, January 15, 2017 12:41 AM -
Sunday, January 15, 2017 12:43 AM
-
Dear Dbguy,
After several hours hard work, finally this URLEncoder and your help solved the problem.
thanks a lot for your help and support.
Public Function URLEncode( _ StringVal As String, _ Optional SpaceAsPlus As Boolean = False _ ) As String Dim bytes() As Byte, b As Byte, i As Integer, space As String If SpaceAsPlus Then space = "+" Else space = "%20" If Len(StringVal) > 0 Then With New ADODB.Stream .Mode = adModeReadWrite .Type = adTypeText .Charset = "UTF-8" .Open .WriteText StringVal .Position = 0 .Type = adTypeBinary .Position = 3 ' skip BOM bytes = .Read End With ReDim result(UBound(bytes)) As String For i = UBound(bytes) To 0 Step -1 b = bytes(i) Select Case b Case 97 To 122, 65 To 90, 48 To 57, 45, 46, 95, 126 result(i) = Chr(b) Case 32 result(i) = space Case 0 To 15 result(i) = "%0" & Hex(b) Case Else result(i) = "%" & Hex(b) End Select Next i URLEncode = Join(result, "") End If End Function
Karim Vaziri Regards,
Sunday, January 15, 2017 7:05 PM -
Hi Karim,
Congratulations! Glad to hear you got it sorted out. Your code should also help others in the same situation.
Good luck with your project.
Sunday, January 15, 2017 8:43 PM