如何使用C#使用PostID喜欢facebook帖子?

时间:2011-09-05 05:29:26

标签: c# asp.net facebook facebook-graph-api

你好朋友我有问题喜欢facebook帖子。 我正在开发asp.net C#中的应用程序
我的代码

 public static string AppendQueryString(string key, string value)
        {
            return string.Format("{0}={1}&", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(value));
        }
   public string PostID { get; private set; }     

 var url = "https://graph.facebook.com/me/feed?access_token=" + <MY_AccessToken>;
 var parameters =   (AppendQueryString("privacy", "{\"value\": \"EVERYONE\"}"))+
      AppendQueryString("message", "hi everybody this is test message");
 var webRequest = WebRequest.Create(url);
            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.Method = "POST";
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(parameters);
            webRequest.ContentLength = bytes.Length;
            System.IO.Stream os = webRequest.GetRequestStream();
            os.Write(bytes, 0, bytes.Length);
            os.Close();

  var webResponse = webRequest.GetResponse();
                StreamReader sr = null;
                try
                {
                    sr = new StreamReader(webResponse.GetResponseStream());
                    this.PostID = sr.ReadToEnd();
                }
                finally
                {
                    if (sr != null) sr.Close();
                }

如何使用PostID喜欢帖子。?

0 个答案:

没有答案