Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: FQL Multiquery

  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts

    FQL Multiquery

    Hello all. I've read through the vague facebook multiquery guide and tried some tutorials online but haven't found an answer to this.

    I'm currently using FQL to access the fb newsfeed. This is my current code which works just fine:

    PHP Code:
    <?php
      
    require_once("../facebook/fbscripts/facebook.php");
      include 
    '../facebook/fbscripts/getfbaccesstoken.php';

    //Get Facebook SDK Object
    $config = array(
      
    'appId'  => 'secret!!!',
      
    'secret' => 'another secret!!!',
     );
     
    $facebook = new Facebook($config);
    $facebook->setAccessToken($useraccesstoken);

         
    //Create Query
        
    $params = array(
            
    'method' => 'fql.query',
            
    'query' => "SELECT post_id, actor_id, target_id, message, comments, likes, description, created_time FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0",
        );

        
    //Run Query
        
    $result $facebook->api($params);

        
    echo 
    "<div class='fbnewsfeedpost'>",
                
    "<div id='fbnewsfeedpic'>","<img src='https://graph.facebook.com/",$result[0]['actor_id'],"/picture?type=square'>","</div>",
                
    "<a id='fbnewsfeedactorid'>",$result[0]['actor_id'],"</a>",
                
    "<a id='fbnewsfeedtargetid'>",$result[0]['target_id'],"</a><br />",
                
    "<a id='fbnewsfeedmessage'>",$result[0]['message'],"</a>",
                
    "<a id='fbnewsfeeddescription'>",$result[0]['description'],"</a>",
                
    "<a id='fbnewsfeedtime'>",$result[0]['created_time'],"</a>",
            
    "</div>";

    I'd like for my 'actor_id' to be the persons name, which means I would need to make another query to the profile tables in facebook to get the users name using his actor_id's user id number.

    My question is, how would I go about doing this with FQL Multiquery? I've tried various methods but haven't been able to get it to work.

    My 2 queries should look like this from what I've read, but I never seem to get it to to work.

    PHP Code:
         //Create Query
        
    $params = array(
    //changed fql.query to fql.multiquery
            
    'method' => 'fql.multiquery',
            
    'query1' => "SELECT post_id, actor_id, target_id, message, comments, likes, description, created_time FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0",
        
    'query2' => "SELECT name FROM profile WHERE id in (SELECT actor_id from #query1)",
    );

        
    //Run Query
        
    $result $facebook->api($params); 
    Sorry for the long post, hope I was detailed enough

  • #2
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts
    I understand. For the situation I'm in, facebook recommends me use the 2nd method I posted. My issue is that the code I posted isn't working. Any ideas as to why?

  • #3
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts
    No ideas? anyone?

  • #4
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Anybody have any idea? = \


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •