- [DEVEXPRESS] Chia sẻ source code cách tạo biểu đồ sơ đồ tổ chức công ty Org Chart trên Winform C#
- [C#] Hướng dẫn tạo Auto Number trên Datagridview winform
- [DATABASE] Hướng dẫn tạo Procedure String Split in Mysql
- [C#] Thiết lập dấu (,) hay dấu (.) ở định dạng số đúng với định dạng số Việt Nam
- [C#] Chia sẻ source code Game Spin Lucky Wheel
- [C#] Hướng dẫn Encode and Decode HTML
- Hướng dẫn tạo tài khoản Chat Open AI GPT tại Việt Nam
- [C#] Hướng dẫn thay đổi giao diện ứng dụng Winform theo giao diện của Windows
- [VB.NET] Hiệu ứng Acrylic, Mica, Tabbed Blur Effect trên Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên Combobox Edit
- [C#] Chia sẻ source code Orange Rain in Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên XtraMessageBox Winform Devexpress 22.2.3
- [DEVEXPRESS] Hướng dẫn sử dụng HTML and CSS Code Viewer trên Winform
- [C#] Number Effect Counter up and down in winform
- [C#] Hướng dẫn Supend and Resume Process ID in Winform
- [C#] Hiển thị line number trên Richtextbox Winform
- [C#] Fake Blue Screen BSOD in winform
- [C#] Chia sẽ code demo sử dụng Async Parallel Foreach and For in Winform
- [C#] Sử dụng ActionBlock run X task at time winform
- [C#] Hướng dẫn sử dụng Property Grid để lưu và tải lại thông tin cấu hình user trên winform
[C#] Hướng dẫn viết ứng dụng gởi tin nhắn private qua facebook
Bài viết hôm nay, mình sẽ hướng dẫn các bạn viết một ứng dụng gởi tin nhắn private qua facebook C#.
[C#] Send a message private from facebook social
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.
Các bạn có thể xem demo mình bên dướ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 = "xxxx@gmail.com"; // 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();
}
}
}
Các bạn có thể tham khảo video hướng dẫn tại đây:
HAVE FUN :)