简体   繁体   English

如何用facebookcsharp sdk查询facebook? (WP8.1通用应用程序)

[英]How to query facebook with facebookcsharp sdk ? (WP8.1 Universal App)

I'm working on a WP8.1 Universal App and I try to use the facebook c# sdk. 我正在开发WP8.1通用应用程序,并且尝试使用facebook c#sdk。

I successfully login to facebook and now I want to make a simple query 我成功登录到Facebook,现在我想进行一个简单的查询

I test this code (from here http://facebooksdk.net/docs/phone/howtos/run-fql-queries/ ) 我测试了这段代码(从这里http://facebooksdk.net/docs/phone/howtos/run-fql-queries/

private async void OnQueryButtonClick(object sender, RoutedEventArgs e)
{
    var fb = new Facebook.FacebookClient(this.loginButton.CurrentSession.AccessToken);
    var result = await fb.GetTaskAsync("fql",
        new
        { 
            q = "SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)" 
        });

    System.Diagnostics.Debug.WriteLine("Result: " + result.ToString());
}

But I get this error: 但是我得到这个错误:

(OAuthException - #12) (#12) fql is deprecated for versions v2.1 and higher (OAuthException-#12)(#12)v2.1和更高版本不建议使用fql

Someone can give a sample of usage of GetTaskAsync ? 有人可以给出GetTaskAsync用法的示例吗?

:-) :-)

var fb - new FacebookClient(this.loginButton.CurrentSession.AccessToken);
fb.GetTaskAsync
(
    "fql",
    new
    { 
        q = "SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)" 
    }
).ContinueWith
(
    t=> 
    if(!t.IsFaulted) 
    {
        dynamic result = t.Result;
        System.Diagnostics.Debug.WriteLine("Result: " + result.ToString());
    }
);

I have not compiled the code above but this should work for a simple Async GetTask call. 我尚未编译上面的代码,但这应该可以用于简单的Async GetTask调用。 Note I recommend moving away from fql facebook api calls. 注意我建议不要使用fql facebook api调用。 FQL is going away with the next version of the Facebook Graph API ( https://developers.facebook.com/docs/reference/fql/ ) batch queries work in place of complex FQL queries. FQL不再使用下一个版本的Facebook Graph API( https://developers.facebook.com/docs/reference/fql/ )批处理查询来代替复杂的FQL查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM