FQL Query to find if member liked page

locknload007

Power Member
Joined
Apr 14, 2010
Messages
554
Reaction score
86
I am looking for a working code to do a query to see if someone has liked a page or not. It seems the code stopped working late last year.

The code I have is

PHP:
$fb_query="SELECT uid FROM page_fan WHERE uid=".$user_id." AND page_id=".$app_id;

Thanks
 
I should add, I can get an array of pages liked using opengraph.
 
that's gonna go over the heads of 99% of people here
better consult an expert
 
Website,

Aren't you in that 1 percent?

What I am wanting to do is reward someone for liking my page. I figure I can then reward them for liking more of my pages, and if I want to get real bold, I could reward them for liking a lot of pages.

I did use http://developers.facebook.com/docs/reference/rest/fql.query to run my query above
PHP:
SELECT uid FROM page_fan WHERE uid=xxxxxxxx AND page_id=xxxxxxxx
adding my id and page id and it did spit out my id.

So that tells me that other parts of the code is messed up.
 
I had read this on that page

Please note: We are in the process of deprecating the REST API, and will be adding equivalent support to the Graph API for this method. You should continue to use this method until we announce support in the Graph API.
 
I had read this on that page

FQL is also being depreciated aswell.

AFAIK, Everything is being rolled into the new "graph api", but in staggers. Use it while it lasts, when they integrate that API call into the new API, they should put a link up.

Their sandbox still works on that page (Which just calls their API anyway), so it is definitely still working.
 
I'm not sure about the FBML but if you can get the graph of likes, then you should be able to look through and check using PHP.
Code:
function checkFan($l,$n, $a){
	global $facebook;
	global $isFan;
	for($i = 0; $i < $n; $i++) {
		$v = $l['data'][$i]['id'];
		$m = $a;
		if ($v == $m){
			return $isFan = 'true';
		}else{
			return $isFan = 'false';
		}
	}
}

Where $l = user_likes (the information you have), $n = total number of likes, and $a is your page id...

Should work or maybe not...;)

HTH
ND
 
Here is some jquery that basically does the same thing as the php above just on the client side (calls the graph and loops through the results while and checking for an id as it progresses through the object).
Code:
var page_id = '1234';
$.getJSON("https://graph.facebook.com/me/likes?callback=?",
	{
		access_token: 'xyz123'
	},
	function(response) {
		$.each(response.data, function(i,data){
			if(response.data[i].id == page_id) alert('You liked ' + page_id);
			if (i == response.data.length) return false;
		});
	}
);
 
I was able to get this to work, to reward 50 coins if they liked the app page. I am storing if they are a fan or not in a database.

PHP:
$user_query=mysql_query("SELECT * FROM ".$user_db." WHERE UserID='$user_id' LIMIT 1");
$user_result=mysql_fetch_assoc($user_query);

if($user_result['IsFan']==0)
{
    
        $fb_query='SELECT uid FROM page_fan  WHERE uid='.$user_id.' AND page_id='.$app_id;

  if($fb_query[0]!=null)
  {
    mysql_query("UPDATE ".$user_db." SET CurrentPoints=CurrentPoints+'$like_amount',IsFan='1' WHERE UserID='$user_id'");
  }
}
 
depreciated????

hmm I don't think I've seen anything about fql being depreciated, just the old rest api. I believe that fql will still be available through the api read tier even after old rest is gone.
 
What on earth is 'depreciated'..? I've never seen anyone call software "depreciated" before.
Depreciated is interchangeable with deprecated. It just means it is being phased out or superseded by an alternative method that is in some form or fashion better than its predecessor.
 
anyone game for setting up an app and give points to those that like certain pages?

I am close, have started setting up a few more tables, one for pages, one for likes.

I think I would pull all pages, they click on a page, they then will go to a page.php?id=1 it will check the page id with the likes table, if they did not like it before, a like button will be displayed, it till then give them the coins, and transfer them back to the list of pages.

Bad thing is that cant give them all that much, so not really worth it for them to be liking pages.
 
What on earth is 'depreciated'..? I've never seen anyone call software "depreciated" before.

From Wikipedia : Depreciated is often confused or used as a stand-in for "deprecated";

I use it since most non programmers understand it as "losing value over time". Which I think basically sums it up in software development terms. :)
 
Yeah, plus deprecated sounds too close for comfort w/ defecated :|
 
Eh. What a load of rubbish. Software development terms my rear-end.

The only thing depreciated and deprecated have in common is they're almost spelled the same.

They have NOTHING to do with each other. Wikipedia is very misleading there saying it's used as a 'stand-in'. It's often CONFUSED for deprecated, not used as a stand-in.

I picked you up on it because you're always going on about being "college-educated" which any real software engineer will laugh at FYI.

Deprecated means that something is being phased out and you should stop using it as the developer's don't guarantee support for the feature in future versions of the software, thus you risk broken code if you ignore it.

How you think that means the same as depreciation, which is something lowering in value is beyond me. Cars depreciate. Computers depreciate. Software features don't depreciate. They have no value.

There is no "lowering of value" over time. The value of the feature is the same as it's always been. It's just not going to be supported in the near future.

I think you need to re-read some of your college books. After all what do us self-taught programmers who built all the open source software that runs the internet know.


If you'd actually admitted you made a mistake in using depreciation rather than deprecation I would have respected you more. The fact you've tried to weesle out of it by pretending you were using terminology for non-programmers is pitiful. All you've done is confuse people and mis-lead them to thinking fql is some how losing its value.

That's OK, I'm not too worried about it.
 
Back
Top