cmehl's Avatar
cmehl 3
5 Asked
8 Answered
1 Best
0
No one has voted on this question yet :(
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!
Tip for best answer: M$2.00
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$

What is Your Answer?

0
0
0

1 Answer

0
warlrus's Avatar
warlrus | 3 years, 1 month ago
3
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

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$
warlrus's Avatar
warlrus | 3 years, 1 month ago Report

Oops! Code hasn't come out very well! I'm sure you can figure it out though :-)

Report Abuse

Post Reply Cancel

Learn something new with our FREE educational apps!

Private lessons in the comfort of your own home. Get back in shape or finally pick up a guitar with our great experts guiding you the whole way!
Learn Guitar
Learn Hip Hop
Learn Pilates