locked
Executing Facebook Query Language(FQL) Queries in windows store apps using java script

    Question

  • Hello,

    I want to execute FQL in java script to retrieve details of friends of a user in fb. I am using FQL with Graph API. I am getting an error while sending GET using xhr.I am providing a sample code how I am doing this please help me.

     WinJS.xhr({ type: 'GET', url: 'https://graph.facebook.com/fql?q=SELECT name,sex from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 =10000098292585)' }).done(function (response) {
            var feedData = JSON.parse(response.responseText);
            var Likes = '';
            for (var i = 0; i < feedData.data.length; i++) {
                Likes += feedData.data[i].name + " " + feedData.data[i].name+"\n";
            }
            var messageDialog = new Windows.UI.Popups.MessageDialog(Likes);
            messageDialog.showAsync();
        });
    I am getting error due to the query.

    I executed the query in facebook developer site https://developers.facebook.com/tools/explorer?method=GET&path=100000982925785%3Ffields%3Did%2Cname I am able to retrieve the result. But when calling from my xhr function I am getting error.



    Thanks and Regards, Jagadish Dharanikota

    Wednesday, October 31, 2012 10:28 AM

Answers

  • Hi,

    I still suggest you test on fiddler first. If you succeed with fiddler. I think winjs.xhr will also no problem.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Thursday, November 01, 2012 7:58 AM
    Thursday, November 01, 2012 5:53 AM
  • Hi,

    My problem got resolved. I had included the access token in my url  and I am able to retrieve details. But its not working in fildler I don't know why.

    Here is the url I used

    https://graph.facebook.com/fql?q=SELECT name,sex from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 =yourid)&access_token='

    + accesstoken


    Thanks and Regards, Jagadish Dharanikota

    Thursday, November 01, 2012 7:28 AM

All replies

  • Hi,

    What is the error?

    And also debug with Fiddler. Using Composer to simulate the process. If the fiddler is no problem, the winjs.xhr should be also correct.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    Thursday, November 01, 2012 3:05 AM
  • Hi,

    Thanks for you reply. I had tried debugging with fiddler. I had send a GET req for this following link

    https://graph.facebook.com/fql?q=SELECT name from user WHERE uid=100000982925785 using Inspector tab in fiddler I got 400 Bad Request message. If I am trying the same url in facebook Graph API Explorer I am getting the user name for the given uid and when I executed in visual studio using my app I am able retrieve user name. The sample code I used for the above is as follows

     

        WinJS.xhr({ type: 'GET', url: SELECT name from user WHERE uid=100000982925785' }).done(function (response) {
            var feedData = JSON.parse(response.responseText);
            var Likes = '';
            for (var i = 0; i < feedData.data.length; i++) {
                Likes += feedData.data[i].name + " " + feedData.data[i].name+"\n";
            }
            var messageDialog = new Windows.UI.Popups.MessageDialog(Likes);
            messageDialog.showAsync();
    
        });


    But when it executing this following link to retrieve my friend details in visual studio I am getting error. Here follows the link

    https://graph.facebook.com/fql?q=SELECT name,sex from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 =100000982925785)

    I have used the same sample code shown below

     WinJS.xhr({ type: 'GET', url: 'https://graph.facebook.com/fql?q=SELECT name,sex from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 =100000982925785)' }).done(function (response) {
            var feedData = JSON.parse(response.responseText);
            var Likes = '';
            for (var i = 0; i < feedData.data.length; i++) {
                Likes += feedData.data[i].name + " " + feedData.data[i].name+"\n";
            }
            var messageDialog = new Windows.UI.Popups.MessageDialog(Likes);
            messageDialog.showAsync();
        });

    The error i am getting for the above code as follows

    Error Message


    Thanks and Regards, Jagadish Dharanikota

    Thursday, November 01, 2012 5:21 AM
  • Hi,

    I still suggest you test on fiddler first. If you succeed with fiddler. I think winjs.xhr will also no problem.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Thursday, November 01, 2012 7:58 AM
    Thursday, November 01, 2012 5:53 AM
  • Hi,

    I have tested it with fiddler its giving me ( 400 Bad Request) message


    Thanks and Regards, Jagadish Dharanikota

    Thursday, November 01, 2012 6:16 AM
  • Hi,

    My problem got resolved. I had included the access token in my url  and I am able to retrieve details. But its not working in fildler I don't know why.

    Here is the url I used

    https://graph.facebook.com/fql?q=SELECT name,sex from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 =yourid)&access_token='

    + accesstoken


    Thanks and Regards, Jagadish Dharanikota

    Thursday, November 01, 2012 7:28 AM