- [C#] Hướng dẫn convert HTML code sang PDF File trên NetCore 7 Winform
- [C#] Hướng dẫn viết ứng dụng chat với Gemini AI Google Winform
- Hướng dẫn khóa file bằng nhiều process id, không cho xóa tập tin
- Hướng dẫn cách tạo Product Id cho ứng dụng phần mềm XXXXX-XXXXX-XXXXX-XXXXX
- [SQLSERVER] Hướng dẫn tạo script sql từ ứng dụng Sqlserver management Studio
- [C#] Hướng dẫn sử dụng thư viện AutoITx lấy id và password Ultraviewer trên winform
- [VB.NET] Hướng dẫn lấy thông tin tài khoản đăng nhập windows và khởi động lại ứng dụng ở chế độ Administrator
- [C#] Sử dụng thư viện Polly gửi lại request api khi request bị lỗi hay rớt mạng
- [DEVEXPRESS] Chia sẻ source code tạo báo cáo report in tem nhãn label trên C# winform
- [DEVEXPRESS] Hướng dẫn vẽ biểu đồ Bar Chart trên Winform
- [C#] Tạo form đăng nhập và đăng ký với hiệu ứng Sliding Animation Effect
- [C#] Hướng dẫn tạo thanh toán đơn hàng qua mã vạch VietQR sử dụng API PayOS hoàn toàn miễn phí
- [C#] Hướng dẫn ghi log ra RichTextBox giống Console trên Winform sử dụng thư viện Serilog
- [C#] Hướng dẫn cách tạo mã QR Code trên file Excel
- [VB.NET] Gởi tin nhắn và file đính kèm qua ứng dụng gởi tin nhắn Whats App
- [C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform
- [TOOL] Chia sẻ phần mềm thay đổi thông tin cấu hình máy tính
- [C#] Hướng dẫn Export dữ liệu ra file Microsoft Word Template
- [C#] Chia sẻ source code tool kiểm tra domain website
- [C#] Hướng dẫn tạo file PDF sử dụng thư viện QuestPDF
[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 :)