...

View Full Version : FQL Multiquery



cloudstryphe
04-15-2012, 06:55 AM
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
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.



//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

cloudstryphe
04-15-2012, 07:37 PM
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?

cloudstryphe
04-16-2012, 11:01 PM
No ideas? anyone? :(

cloudstryphe
04-18-2012, 06:23 AM
Anybody have any idea? = \



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum