2

PHP / FACEBOOK'S FQL

Thank you for even reading this.

I'm having some serious inception issues, dream within a dream style.

I'm doing a multiquery to get the last 3 places a friend visited. I need to show [timestamp] from the location_post table and then [name] of the place from the page table. Hence the multiquery.

now, i get all the values when i check with print_r. However, when I try to echo it, I'm having serious issues getting into the array.

$query = array(
        "theVisit"=>"SELECT page_id, timestamp 
                     FROM location_post 
                     WHERE author_uid=XXXXXXXX LIMIT 3",

        "thePlace"=>"SELECT name 
                     FROM page 
                     WHERE page_id IN (SELECT page_id FROM #theVisit) 
                     LIMIT 3"
);

$fql_url = $facebook->api(array(
    'method' => 'fql.multiquery',
    'queries' => $query
));

So far so good. Now I try to get into the array.

echo $fql_url[0]["name"]["fql_result_set"];

This prints just this: t

(just the letter t)

same goes for doing this:

echo $fql_url[0]["name"][0];
// Prints: t    

I can't get my head around it. i've tried thousands of variations to get to the data but just can't get to it.

the fql_result_set seems like the obvious villain.

$fql_url[0]["name"]["theVisit"][0]["page_id"] etc, but it just kills everything that happens in the code after that.

below is the array I get from print_r

Array ( 
  [0] => Array ( 
         [name] => theVisit [fql_result_set] => Array ( 
                            [0] => Array ( 
                                                       [page_id] => 6205957466 
                                                       [timestamp] => 1349138499 
                                                       ) 
                                                ) 
         )

   [1] => Array ( 
          [name] => thePlace [fql_result_set] => Array ( 
                                                 [0] => Array ( 
                                                       [name] => Best Buy Theater 
                                                       ) 
                                                 ) 
                 ) 

)
Petter
  • 49
  • 2
  • Well I was a bit retarded. [fql_result_set] obviously not inside ["theVisit"]. I realized this and can easily echo what I need like this echo $fql_url[0]["fql_result_set"][0]["page_id"]; this prints the correct page_id: 6205957466 – Petter Oct 11 '12 at 01:25

1 Answers1

0

Well I was a bit retarded.

[fql_result_set] is obviously not nested inside ["theVisit"], which I stupidly thought.

I realized this and can easily echo what I need like this

 echo $fql_url[0]["fql_result_set"][0]["name"];

this prints the correct page_id (6205957466)

Petter
  • 49
  • 2