wilyfox
یک شنبه 17 اسفند 1393, 20:45 عصر
سلام.میخوام یه درخواست رو به یه صفحه وب بفرستم و جواب اونو بگیرم .ولی اررور میده .وقتی با html تست کردم درست کار میکرد و لی با برنامه نمیشه.:
این سورس کد :
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Charge_Viewer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string SendPost(string url, string postData)
{
string webpageContent = string.Empty;
try
{
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = byteArray.Length;
using (Stream webpageStream = webRequest.GetRequestStream())
{
webpageStream.Write(byteArray, 0, byteArray.Length);
}
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
{
webpageContent = reader.ReadToEnd();
}
}
}
catch (Exception ex)
{
//throw or return an appropriate response/exception
}
return webpageContent;
}
private void Form1_Load(object sender, EventArgs e)
{
string a = SendPost("http://accounting.hamyar.net/IBSng/user/", "normal_username=****&normal_password=*****");
MessageBox.Show(a);
}
}
}
و اینم اررور :
---------------------------
---------------------------
<br />
<b>Fatal error</b>: Call to undefined function http_response_code() in <b>/usr/local/IBSng/interface/IBSng/inc/auth.php</b> on line <b>138</b><br />
---------------------------
OK
---------------------------
username و password رو پاک کردم.
این سورس کد :
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Charge_Viewer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string SendPost(string url, string postData)
{
string webpageContent = string.Empty;
try
{
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = byteArray.Length;
using (Stream webpageStream = webRequest.GetRequestStream())
{
webpageStream.Write(byteArray, 0, byteArray.Length);
}
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
{
webpageContent = reader.ReadToEnd();
}
}
}
catch (Exception ex)
{
//throw or return an appropriate response/exception
}
return webpageContent;
}
private void Form1_Load(object sender, EventArgs e)
{
string a = SendPost("http://accounting.hamyar.net/IBSng/user/", "normal_username=****&normal_password=*****");
MessageBox.Show(a);
}
}
}
و اینم اررور :
---------------------------
---------------------------
<br />
<b>Fatal error</b>: Call to undefined function http_response_code() in <b>/usr/local/IBSng/interface/IBSng/inc/auth.php</b> on line <b>138</b><br />
---------------------------
OK
---------------------------
username و password رو پاک کردم.