Giter Site home page Giter Site logo

Comments (2)

prabirshrestha avatar prabirshrestha commented on June 26, 2024

Query and QueryAsync made more sense when using with fql. but now with graph api it is very simple. (fb c# sdk supports the following codes since https://github.com/facebook-csharp-sdk/facebook-csharp-sdk/tree/f1f1cebc73111bea5e9f5268befb8baf0779f637)
also issue #8 would cause breaking changes anyway.

Here is the new way to execute fql using graph api.

Single FQL:

var result = fb.Get("fql", new { q = "SELECT uid from user where uid=me()" });

MultiQuery FQL:

var resultMulti = fb.Get("fql", new
                                    {
                                        q = new[]
                                                {
                                                    "SELECT uid from user where uid=me()",
                                                    "SELECT name FROM user WHERE uid=me()"
                                                }
                                    });

Named multi-query:

var resultMultiNamed = 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)",
                                    }
                                });

from facebook-csharp-sdk.

prabirshrestha avatar prabirshrestha commented on June 26, 2024

Here is the how to execute fql using async methods.

Single Query

var fb = new FacebookClient(accessToken);
var mrs = new ManualResetEvent(false);

fb.GetCompleted += (o, e) =>
                        {
                            if (e.Cancelled)
                            {
                                Console.WriteLine("cancelled");
                                return;
                            }
                            else if (e.Error != null)
                            {
                                Console.WriteLine(e.Error.Message);
                                return;
                            }

                            var result = e.GetResultData();
                            Console.WriteLine(result.ToString());
                        };

fb.GetAsync("fql", new { q = "SELECT uid from user where uid=me()" });

MultiQuery

var fb = new FacebookClient(accessToken);

fb.GetCompleted += (o, e) =>
{
    if (e.Cancelled)
    {
        Console.WriteLine("cancelled");
        return;
    }
    else if (e.Error != null)
    {
        Console.WriteLine(e.Error.Message);
        return;
    }

    var result = e.GetResultData();
    Console.WriteLine(result.ToString());
};

fb.GetAsync("fql",
            new
                {
                    q = new[]
                            {
                                "SELECT uid from user where uid=me()",
                                "SELECT name FROM user WHERE uid=me()"
                            }
                });

Named MultiQuery

var fb = new FacebookClient(accessToken);

fb.GetCompleted += (o, e) =>
{
    if (e.Cancelled)
    {
        Console.WriteLine("cancelled");
        return;
    }
    else if (e.Error != null)
    {
        Console.WriteLine(e.Error.Message);
        return;
    }

    var result = e.GetResultData();
    Console.WriteLine(result.ToString());
};

fb.GetAsync("fql",
            new
                {
                    q = new
                            {
                                id = "SELECT uid from user where uid=me()",
                                name = "SELECT name FROM user WHERE uid IN (SELECT uid FROM #id)",
                            }
                });

from facebook-csharp-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.