PDA

View Full Version : تبدیل یک function ای اس پی به یک تابع در aspx



crazy_1892
چهارشنبه 13 مهر 1390, 18:32 عصر
سلام دوستان گلم
من این فانکشن را سایت کپی گرفتم و اینجا میذارم
میشه به یک تابع در aspx تبدیل کنید برام


Function SMSSEND(username,password,too,text)
sMsg = server.urlencode(text)
sBaseUrl = "http://www.azadsms.com/API_sendsms.asp"
set objHTTP = Server.CreateObject("msxml2.XMLHTTP")
objHTTP.open "POST", sBaseUrl, False
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.send "username=" & username & "&password=" & password & "&to=" & too & "&text=" & sMsg
SMS_SEND = objHTTP.responseText
Set objHTTP = Nothing
End Function
response.write SMSSEND("username","password","09120009999","tttttttssst")

crazy_1892
پنج شنبه 14 مهر 1390, 18:43 عصر
دوستان کسی نیست این کارو برام انجارم بده؟؟؟؟

crazy_1892
شنبه 16 مهر 1390, 11:16 صبح
تو رو خدا یکی اینو برای من تبدیل کنه!!!

exlord
یک شنبه 17 مهر 1390, 14:11 عصر
public WebResponse SMSSEND(string username, string password, string too, string text)
{
string sMsg = Server.UrlEncode(text);
string sBaseUrl = "http://www.azadsms.com/API_sendsms.asp";
string data = "username=" + username + "&password=" + password + "&to=" + too + "&text=" + sMsg;
byte[] data_byte = Encoding.UTF8.GetBytes(data);
WebRequest objHTTP = WebRequest.Create(sBaseUrl);
((HttpWebRequest)objHTTP).UserAgent = ".NET Framework Example Client";
objHTTP.Method = "POST";
objHTTP.ContentLength = data_byte.Length;
objHTTP.ContentType = "application/x-www-form-urlencoded";

Stream dataStream = objHTTP.GetRequestStream();

dataStream.Write(data_byte, 0, data_byte.Length);
dataStream.Close();

return objHTTP.GetResponse();
}