Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ช่วยแกะโค๊ด asp เป็น asp.net คือผมจะเขียนโค๊ด ส่ง sms โดยผมใช้วิธีเชื่อมต่อกับ sms Gateway



 

ช่วยแกะโค๊ด asp เป็น asp.net คือผมจะเขียนโค๊ด ส่ง sms โดยผมใช้วิธีเชื่อมต่อกับ sms Gateway

 



Topic : 029712

Guest




คือผมจะเขียนโค๊ด ส่ง sms โดยผมใช้วิธีเชื่อมต่อกับ sms Gateway ที่เขาให้บริการ แล้วเว็บที่ให้บริการนั้นเขามีเฉพาะตัวอย่างการเชื่อมต่อด้วยภาษา asp แต่ผมต้องการเขียนเป็น asp.net ด้วย c# ผมต้องแก้ไขอะไรบ้างครับ
Code (ASP)
<%
' ปรับปรุงล่าสุด 22/05/2551 (รองรับ ทั้งภาษาไทยและภาษาอังกฤษ)
'
' - กรณีที่ส่งค่า lang=T และ ส่งข้อความเกิน 70 ตัวอักษร ระบบจะตัดอักษรที่เกินทิ้งไป
' - กรณีที่ส่งค่า lang=E และ ส่งข้อความเกิน 160 ตัวอักษร ระบบจะตัดอักษรที่เกินทิ้งไป
' - ตัวอักษรและสัญลักษณ์ที่ถือว่าเป็นภาษาอังกฤษได้แก่ A-Z a-z 0-9 เว้นวรรค แท็บ และ 
'   ! @ # $ % ^ & * ( ) _ + | \ = - [ ] { } ; : ' " , . / < > ? เท่านั้น นอกนั้นถือว่าเป็นภาษาไทย
' - อย่าลืมนำข้อความที่จะส่งมาผ่านฟังก์ชั่น Server.URLEncode() ก่อน
'   ไม่เช่นนั้น ท่านจะส่งเครื่องหมาย + = & ไม่ได้
' - ดาวโหลด MSXML ได้ที่ http://msdn.microsoft.com/xml/

strRecipient="0819871234"
strSMSAccount="user"
strSMSPassword="pass"
strLang="T"
strMessage="ทดสอบการส่งข้อความผ่านระบบ API"
strMessageX=Server.URLEncode(strMessage)

strData = "msisdn=" & strRecipient & "&user=" & strSMSAccount & "&pass=" & strSMSPassword & "&lang=" & strLang & "&msg=" & strMessageX
Set xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlHTTP.Open "POST", "http://smsgateway.applymail.com/api/send.php", False
xmlHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHTTP.SetRequestHeader "Content-Length", Len(strData)
xmlHTTP.SetRequestHeader "Connection", "close"
xmlHTTP.Send strData
strReturn = xmlHTTP.ResponseText
Set xmlHTTP = Nothing

Dim a
Dim status
Dim detail
a=Split(strReturn,"<STATUS>")
status=Split(a(1),"</STATUS>")

if status(0) = "OK" then
     Response.Write "ส่งสำเร็จ"
     else
     a=Split(strReturn,"<DETAIL>")
     detail=Split(a(1),"</DETAIL>")
     Response.Write "ส่งไม่สำเร็จ เนื่องจาก " & detail(0)
     end if

%>


ช่วยโค๊ดให้ดูเป็นตัวอย่างด้วยนะครับ
ขอความช่วยเหลือด้วยครับ ขอบคุณมากครับ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-07-29 16:27:52 By : different View : 3105 Reply : 7
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ปกติมันก็ใช้เกือบจะได้เลยน่ะครับ แก้นิด ๆ หน่อย ๆ ครับ






Date : 2009-07-29 16:37:51 By : webmaster
 


 

No. 2

Guest


แต่ผมนำไปดัดแปลงให้อยู่ในรูปของ asp.net ด้วย c# มัน compile ไม่ผ่านครับ
และถ้าใช้เป็น vb เราต้อง import Namespace อะไรเข้ามาใช้บ้างครับ
Date : 2009-07-29 22:45:59 By : different
 

 

No. 3



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim strRecipient As String = "0819871234"
        Dim strSMSAccount As String = "user"
        Dim strSMSPassword As String = "pass"
        Dim strLang As String = "T"
        Dim strMessage As String = "ทดสอบการส่งข้อความผ่านระบบ API"
        Dim strMessageX As String = Server.UrlEncode(strMessage)

        Dim strData As String = "msisdn=" & strRecipient & "&user=" & strSMSAccount & "&pass=" & strSMSPassword & "&lang=" & strLang & "&msg=" & strMessageX
        Dim xmlHTTP As Object = CreateObject("MSXML2.ServerXMLHTTP")
        xmlHTTP.Open("POST", "http://smsgateway.applymail.com/api/send.php", False)
        xmlHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
        xmlHTTP.SetRequestHeader("Content-Length", Len(strData))
        xmlHTTP.SetRequestHeader("Connection", "close")
        xmlHTTP.Send(strData)
        Dim strReturn As String = xmlHTTP.ResponseText
        xmlHTTP = Nothing

        Dim a() As String
        Dim status() As String
        Dim detail() As String
        a = Split(strReturn, "<STATUS>")
        status = Split(a(1), "</STATUS>")

        If status(0) = "OK" Then
            Response.Write("ส่งสำเร็จ")
        Else
            a = Split(strReturn, "<DETAIL>")
            detail = Split(a(1), "</DETAIL>")
            Response.Write("ส่งไม่สำเร็จ เนื่องจาก " & detail(0))
        End If
    End Sub

End Class


ลองแล้วมัน Error 202 ครับ ต้องลองถามทางผู้ให้บริการว่า error นี้แปลว่าอะไร สงสัย user กับ password ไม่ถูกต้อง
Date : 2009-08-10 23:30:51 By : jnithi
 


 

No. 4

Guest


แล้วถ้าเป็น PHP นี่ต้องใช้ code แบบไหนคับ
Date : 2010-09-23 11:14:06 By : keng
 


 

No. 5

Guest


อยากได้เป็น c# อะคับ รบกวนขอด้วยยย คับ
Date : 2010-11-16 01:37:30 By : ต้นไม้
 


 

No. 6



โพสกระทู้ ( 10 )
บทความ ( 0 )



สถานะออฟไลน์


ตอนนี้ผมกำลังทำโปรเจคแล้วมีsms เข้มาด้วยอยากถามว่าเจ้าของกระทู้ต้องติดต่อที่ไหนอะครับเกี่ยวกับ sms Gateway และค่าใช่จ่ายแพงไหมคับ
Date : 2010-11-16 02:05:05 By : jom_wirayut
 


 

No. 7



โพสกระทู้ ( 44 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่รู้เกี่ยวมั้ย นะครับ แต่ว่าได้ยางไงแล้ว ช่วย มา post code ให้ดูกันบ้างนะครับ
เพราะว่าผมก็จะทำเหมือนกันเลยครับแต่ว่าผมใช้ .net ครับ vb or c# ได้หมด อิๆๆ ขอบคุณครับ

// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create ("http://www.contoso.com/PostAccepter.aspx ");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "This is a test that posts this string to a Web server.";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream ();
// Write the data to the request stream.
dataStream.Write (byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close ();
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status.
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Clean up the streams.
reader.Close ();
dataStream.Close ();
response.Close ();
Date : 2010-11-16 08:42:31 By : mahapali
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยแกะโค๊ด asp เป็น asp.net คือผมจะเขียนโค๊ด ส่ง sms โดยผมใช้วิธีเชื่อมต่อกับ sms Gateway
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่