Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying all public facebook posts

I need to build an application that will have three input fields for three URLs. Application then needs to search all public posts on facebook and find users who posted that specific URLs. I'm using this code:

$q = "http://www.someurl.com";
$search = $facebook->api('/search?q=' . $q .'&type=post&limit=200');
foreach ($value as $fkey=>$fvalue) {
    if(isset($fvalue['from']['name']))
    {
        echo $fvalue['from']['name']."<br />";
    }
    }}

This prints out 200 facebook user's names that posted one specific link. But, as I mentioned above, I need to search for multiple URL match. By using this approach, I would need to make three query calls and then cross-reference results and get users that appear on all three result lists. Is there any way to form query to return needed results in just one call? I now that FQL is powerful tool, but I think that it cannot be used for this kind of public queries. Am I really limited only to public graph api? And if that is the case, is it possible to form complex query using only graph api?

EDIT#1: I tried using following FQL:

SELECT source_id FROM stream WHERE
CONTAINS('http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic') 
AND CONTAINS('http://kotaku.com/5917693/ten-years-of-civ-ii-lock-the-world-in-perpetual-war') 
AND CONTAINS('http://www.youtube.com/watch?v=1TBxdXm3DP0') limit 200

As I understand, this should return users who have these three links in their fb stream. However, that is not the case. Am I getting this all wrong?

like image 989
Xardas Avatar asked Dec 15 '13 12:12

Xardas


2 Answers

A simpler approach will be to just check the presence of a URL in the message part of the Post. This fql should work:

SELECT message FROM stream WHERE CONTAINS("http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic") 
AND strpos(message,'http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic') >=0

Similarly, to search for a post containing all three links you can extend the fql further.

SELECT message FROM stream WHERE CONTAINS("http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic") 
AND strpos(message,'http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic') >=0 
AND CONTAINS("http://kotaku.com/5917693/ten-years-of-civ-ii-lock-the-world-in-perpetual-war") 
AND strpos(message,'http://kotaku.com/5917693/ten-years-of-civ-ii-lock-the-world-in-perpetual-war') >=0 
AND CONTAINS("http://www.youtube.com/watch?v=1TBxdXm3DP0") 
AND strpos(message,'http://www.youtube.com/watch?v=1TBxdXm3DP0') >=0 
like image 193
Rahil Arora Avatar answered Oct 17 '22 01:10

Rahil Arora


it is no longer possible since facebook disabled public post searching in mid December 2013.

like image 27
Burlwood Barry Avatar answered Oct 17 '22 01:10

Burlwood Barry