- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
- [C#] Hướng dẫn cách lấy thông tin đăng nhập tài khoản và mật khẩu web browser trên windows
- [VB.NET] CRUD Thêm xóa sửa tìm kiếm Realtime FireBase
- [C#] Hiển thị thông báo Toast Message trong lập trình Winform
- [C#] Cấu hình định dạng ngày tháng, thời gian trên Windows cho ứng dụng Winform
- [C#] Rút gọn đường dẫn link url với TinyURL API
- [C#] Hướng dẫn cách bo tròn winform with Radius
- [C#] Chia sẽ class BackGroundOverlay Show Modal cho Winform
- [C#] Hướng dẫn Flip Image Winform
- [C#] Invoke là gì? cách sử dụng phương thức Invoke()
- [C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
[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 :)