- [C#] Viết ứng dụng xem và dò kết quả xổ số kiến thiết miền nam
- [EBOOK] Chia sẽ giáo trình học lập trình C - Giáo sư Phạm Văn Ất
- [C#] Hướng dẫn viết ứng dụng theo dõi máy in bao nhiêu trang (Monitor Printer)
- [C#] Lấy thông tin cấu hình máy tính xuất ra text file winform
- [C#] Chia sẽ class Install, Uninstall, Start và Stop Services Winform
- [C#] Tìm kiếm tập tin file nhanh chóng trên Winform sử dụng thư viện FastSearchLibrary
- [C#] Giới thiệu thư viện Fluent FTP Awesome dùng để làm việc với FTP
- [C#] Sử dụng thư viện Mini Profiler Integrations ghi log thực hiện các câu lệnh SQL
- [DEVEXPRESS] Thiết kế Dropdown ButtonBarItem trên Form Ribbon
- [C#] Lưu trạng thái các control trên Winform vào Registry Windows
- [C#] Ứng dụng ví dụ Simple Observer Pattern tăng giảm số lượng trên winform
- [C#] Hướng dẫn lấy thời gian thực server time trên winform
- [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#] 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 :)