Facebook使用HTTP请求发送消息

时间:2015-01-07 12:41:35

标签: c# .net facebook http request

我想在facebook上发送消息。这是我发布帖子请求的方法:

 public static string http_post(string url, string data)
        {
            var cookiespost = new CookieContainer();
            ServicePointManager.Expect100Continue = false;

            var request = (HttpWebRequest)WebRequest.Create(url);
            request.CookieContainer = cookiespost;
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            using (var requestStream = request.GetRequestStream())
            using (var writer = new StreamWriter(requestStream))
            {
                writer.Write(data);
            }

            using (var responseStream = request.GetResponse().GetResponseStream())
            using (var reader = new StreamReader(responseStream))
            {
                var result = reader.ReadToEnd();
                cookies = cookiespost;
                return result;

            }
        }

数据:

"fb_dtsg=AQHcmRlBsZsj&charset_test=%E2%82%AC%2C%C2%B4%2
 C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&ids%
 5B100002079663653%5D=100002079663653&text_ids%
 5B100002079663653%5D=%D0%9D%D0%B8%D0%BA%D0%B8%D1%
 82%D0%B0+%D0%A5%D0%B8%D0%B6%D0%BD%D1%8F%D0%BA&body="
 + textofmessage + "&Send=%D0%9D%D0%B0%D0%B4%
 D1%96%D1%81%D0%BB%D0%B0%D1%82%D0%B8";

URL:

https://m.facebook.com/messages/send/?icm=1

但是我收到登录页面的回复文本中没有发送消息。

如何才能执行发送消息?

谢谢!

0 个答案:

没有答案