Fql facebook api查询

时间:2012-10-28 12:47:57

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

 var webRequest = (HttpWebRequest)HttpWebRequest.Create("https://graph.facebook.com/");
            webRequest.Method = "POST";
            webRequest.ContentType = "application/x-www-form-urlencoded";

            var requestString = "fql?q=SELECT status_id, message FROM status 
               WHERE uid=me()";

            byte[] bytedata = Encoding.UTF8.GetBytes(requestString);

            webRequest.ContentLength = bytedata.Length;

            var requestStream = webRequest.GetRequestStream();
            requestStream.Write(bytedata, 0, bytedata.Length);
            requestStream.Close();

            var response = webRequest.GetResponse();
            var responseStream = new StreamReader(response.GetResponseStream());
            var responseString = responseStream.ReadToEnd();

我正在尝试获取上面代码的fb帐户的状态消息抛出错误的请求,并且这个使用facebook api获取请求说无效参数

                string accessToken = ViewState["accessToken"].ToString();
            Facebook.FacebookClient fb = new FacebookClient(accessToken);
            dynamic me = fb.Get("/me");

            var id = me.id;

            string query = "SELECT status_id, message FROM status WHERE uid=me()";

            var posts = fb.Get("/fql?q=SELECT status_id, message FROM status WHERE uid=me()");

任何帮助将不胜感激.. facebook给我headbangings ..:\ 最后一点是上面的查询在fql图形api模拟器中完美无缺

https://developers.facebook.com/tools/explorer?method=GET&path=uridfields%3Did%2Cname

1 个答案:

答案 0 :(得分:0)

我想你正在寻找这个:Facebook Graph API - User
在Connections下,您将找到“状态”。

为了获得所有状态的数组,您必须致电/me/statuses?access_token=ACCESS_TOKEN 您必须获得read_stream权限。

希望我能提供帮助。

编辑: 如果是WinRT: 我会以另一种方式调用Graph API(不知道它是否更好但它也有效):

// Example Uri
Uri requestUri = new Uri("https://graph.facebook.com/me/statuses?access_token=ACCESS_TOKEN");    

HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(requestUri);

string content = await response.Content.ReadAsStringAsync();
return content;