[C#] Hướng dẫn viết ứng dụng gởi tin nhắn private qua facebook
Nếu các bạn muốn gởi tin nhắn qua facebook bằng app. Thì các bạn có thể viết bằng thủ thuật mình hướng dẫn bên dưới.Vì mặc định, Facebook chống spam tin nhắn, nên các bạn sẽ tìm API send private a message to Facebook sẽ không có nhé các bạn.
Để lấy được id_sender của facebook các bạn có thể tham khảo thêm video ở cuối bài.
Source code C#
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; using xNet; namespace sendFacebookMessage { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void btnSend_Click(object sender, EventArgs e) { string email = "[email protected]"; // nhap email của bạn string password = "mat khau"; // nhap mat khau cua ban o day HttpRequest http = new HttpRequest(); http.Cookies = new CookieDictionary(); http.UserAgent = Http.FirefoxUserAgent(); string html = http.Get("https://m.facebook.com").ToString(); //Test(html); string lsd = Regex.Match(html, "name="lsd" value="(.*?)"").Groups[1].Value; string type = "application/x-www-form-urlencoded"; string urlLogin = "https://m.facebook.com/login.php"; string data = "lsd=" + lsd + "&m_ts=1502509596&li=HHqOWduNRyxgj_bHQgsyFVjB&try_number=0&unrecognized_tries=0&email=" + email + "&pass=" + password + "&login=%C4%90%C4%83ng+nh%E1%BA%ADp"; html = http.Post(urlLogin, data, type).ToString(); //Test(html); //send ok string fb_dtsg = Regex.Match(html, "name="fb_dtsg" value="(.*?)"").Groups[1].Value; string content = txtMessage.Text; string urlSend = "https://m.facebook.com/messages/send/?icm=1&refid=12"; string friend_id = "id.158017867633548"; string dataSend = "fb_dtsg=" + fb_dtsg + "&body=" + content + "&send=G%E1%BB%ADi&tids="+ friend_id +"&wwwupp=C3&wwwupp=C3&ids%5B100006313591670%5D=100006313591670&referrer=&ctype=&cver=legacy&csid=f2a3f319-7eab-3f4a-376e-30898e3e9987"; html = http.Post(urlSend, dataSend, type).ToString(); } } }
VIDEO DEMO THỦ THUẬT.
Theo LapTrinhVB.Net
No comments:
Post a Comment