7

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?

Xardas
  • 1,777
  • 6
  • 20
  • 31

2 Answers2

2

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 
Rahil Arora
  • 3,644
  • 3
  • 26
  • 43
  • Thanks for answering. Did you test this query with Graph API Explorer tool? It should work with posts from my own wall, I've set their privacy to public. I can't get any results no matter what link combination I enter. I think we are missing something... – Xardas Dec 21 '13 at 11:50
  • You are right. The behavior is strange! I tested the first query using graph explorer and it is working fine. However, it is not showing any results for multiple URLs. – Rahil Arora Dec 21 '13 at 16:28
  • I even tried out `SELECT message FROM stream WHERE CONTAINS("http://vimeo.com") AND strpos(message,'http://vimeo.com') >=0 AND CONTAINS("http://www.youtube.com") AND strpos(message,'http://www.youtube.com') >=0` and it returned a few results. – Rahil Arora Dec 21 '13 at 17:13
1

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

  • As Wikipedia would say, citation required. A link to the post on Facebook's official documentation would really help "sell your point" :) – javatarz Dec 24 '13 at 04:52