3 years, 1 month ago
Is there a line of code that I can use to display the number of fans of a certain facebook public profile page as text on another website?
If anyone can figure this out, please reply and I will gladly tip you for working code. Thanks!
Separate topics with commas, or by pressing return. Use the delete or backspace key to edit or remove existing topics.
You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.
M$1 Answer
You will be able to use PHP and the fopen command:
code
$page = fopen("http://www.facebook.com/pages/Chuck/9110481207", r);
?>
/code
Using Chucks page for an example here!
You'd then need to do some regular expressions on the result. The HTML around the fans bit on Chucks page looks like this:
code
ChuckTV Programme101,492 fans
/code
This will be in a similar format for any page, just with the variables changed. You'll be able to get all of the variables from whichever page you're using, but if you use preg_match() or similar, and take whatever is in between the final as your number, then strip the 'fans' off the end - you have the number of fans!
Point of note here - Facebook can be ridiculously slow to load up in this manner, and may possibly start rejecting connections - use at your own risk, and don't make this script critical to the page loading. Unfortunately thats just a fact of cross-site loading!
I would write you up some working code, feel free to tempt me with a nice large tip for that, but quite frankly - its 1am here and I absolutely hate regex :-D
code
$page = fopen("http://www.facebook.com/pages/Chuck/9110481207", r);
?>
/code
Using Chucks page for an example here!
You'd then need to do some regular expressions on the result. The HTML around the fans bit on Chucks page looks like this:
code
ChuckTV Programme101,492 fans
/code
This will be in a similar format for any page, just with the variables changed. You'll be able to get all of the variables from whichever page you're using, but if you use preg_match() or similar, and take whatever is in between the final as your number, then strip the 'fans' off the end - you have the number of fans!
Point of note here - Facebook can be ridiculously slow to load up in this manner, and may possibly start rejecting connections - use at your own risk, and don't make this script critical to the page loading. Unfortunately thats just a fact of cross-site loading!
I would write you up some working code, feel free to tempt me with a nice large tip for that, but quite frankly - its 1am here and I absolutely hate regex :-D
You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.
M$
Oops! Code hasn't come out very well! I'm sure you can figure it out though :-)