如何使用 C# Facebook SDK 进行命名多重查询

发布于 2024-12-17 07:39:27 字数 801 浏览 2 评论 0原文

我正在将一些遗留代码从旧的 3.0 版本的 C# Facebook SDK 更新到新的 5.3.2 版本。

http://developers.facebook.com/docs/reference/fql/ 它表明您可以执行如下多重查询:

"query1":"SELECT uid, rsvp_status FROM event_member WHERE eid=12345678"
"query2":"SELECT name, url, pic FROM profile WHERE id IN (SELECT uid FROM #query1)"

在旧 API 中,您只需拥有一个字典,其中每个查询都与其名称配对:

"page_admin_list","SELECT uid, page_id, type FROM page_admin where uid = 1234567890"
"permissions_response","SELECT uid, read_stream, status_update, photo_upload, publish_stream, offline_access FROM permissions WHERE uid IN (SELECT page_id FROM #page_admin_list)"

在每个示例中,请注意嵌套查询中的 #。但是,我不确定如何使用新语法来完成此操作,因为它只接受 string[] 作为参数。

I'm updating some legacy code from the old 3.0 version of the C# Facebook SDK to the new 5.3.2 version.

On http://developers.facebook.com/docs/reference/fql/
it shows that you can do a multiquery like:

"query1":"SELECT uid, rsvp_status FROM event_member WHERE eid=12345678"
"query2":"SELECT name, url, pic FROM profile WHERE id IN (SELECT uid FROM #query1)"

In the old API, you'd just have a Dictionary where each query was paired up with it's name:

"page_admin_list","SELECT uid, page_id, type FROM page_admin where uid = 1234567890"
"permissions_response","SELECT uid, read_stream, status_update, photo_upload, publish_stream, offline_access FROM permissions WHERE uid IN (SELECT page_id FROM #page_admin_list)"

In each of the examples, notice the # in the nested query. However, I'm unsure how to accomplish this with the new syntax since it is only accepting string[] as the parameter.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

櫻之舞 2024-12-24 07:39:27

从 Facebook C# SDK v6 开始,您可以使用以下方法执行命名查询。

var fb = new FacebookClient("access_token");
dynamic result = fb.Get("fql",
    new
        {
            q = new
            {
                id = "SELECT uid from user where uid=me()",
                name = "SELECT name FROM user WHERE uid IN (SELECT uid FROM #id)",
            }
        });

Starting from Facebook C# SDK v6 you can execute named queries using the following method.

var fb = new FacebookClient("access_token");
dynamic result = fb.Get("fql",
    new
        {
            q = new
            {
                id = "SELECT uid from user where uid=me()",
                name = "SELECT name FROM user WHERE uid IN (SELECT uid FROM #id)",
            }
        });
老旧海报 2024-12-24 07:39:27

找到这个答案(编辑这适用于早期版本的 sdk,对于版本 6 及更高版本,请参阅 prabir 的答案):
我必须通过 #query0、#query1 等引用每个查询...

或者我可以使用 Get() 方法而不是 Query() 方法

var queries = 
    new Dictionary<string, object>
    {
        { "FamDamly", "select uid from family where profile_id = me()" },
        { "FamDetails", "select uid, first_name from user where uid in #FamDamly" }
    };
client.Get(queries);

Found this answer (edit: this applies to the earlier versions of the sdk, for version 6 and above see prabir's answer) :
I have to reference each query by #query0, #query1, etc...

Or I can use the Get() method rather than the Query() method

var queries = 
    new Dictionary<string, object>
    {
        { "FamDamly", "select uid from family where profile_id = me()" },
        { "FamDetails", "select uid, first_name from user where uid in #FamDamly" }
    };
client.Get(queries);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文