Merhabalar ;
Ben HttpWebRequest ile facebook'a bağlanıp ordan mesajlarıma bakacak bir program yapmaya çalışıyorum. Bağlanabiliyorum ve bakabiliyorum. Sorun şu her kontrolde yeniden giriş yapıyorum tek bir sefer giriş yapıp 5 snde bir kontrol etmek istiyorum ama olmuyor kodları yazayım, bakrsanız sevinirim
public partial class Form1 : Form
{
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://m.facebook.com/login.php?http");
public Form1()
{
InitializeComponent();
}
public int FacebookLogin()
{
string strMail = "email";
string strPass = "sifre";
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "email=" + strMail;
postData += ("&pass=" + strPass);
byte[] data = encoding.GetBytes(postData);
// Web Request
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(data, 0, data.Length);
newStream.Close();
return 0;
}
public int FacebookKontrol()
{
string html = string.Empty;
using (HttpWebResponse resp = (HttpWebResponse)myRequest.GetResponse())
{
bool isSuccess = (int)resp.StatusCode < 299 && (int)resp.StatusCode >= 200;
if (isSuccess)
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
{
html = reader.ReadToEnd();
}
}
}
string str = html;
int idx;
idx = str.IndexOf("Gelen Kutusu (1)");
if (idx > 0)
MessageBox.Show("Mesaj VAR!");
return 0;
}
private void Form1_Load(object sender, EventArgs e)
{
FacebookLogin();
}
private void timer1_Tick(object sender, EventArgs e)
{
FacebookKontrol();
}
}