Ask questions via twitter! Message any question to @answers on twitter. We'll publish the question and send you a reply each time there's a new answer.
Next Question

Answered Question

 
M$2.00  Funded By Mahalo ? |  April 21, 2009 07:13 PM

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!
Interesting Question?  Yes (0)   No (0)   
RSS
 
 

Best Answer  Chosen by Asker

 
April 22, 2009 12:04 AM
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
Asker's Rating:


Helpful Answer?  (0)   (0)    Tip warlrus for this answer
Permalink | Report
   Reply  
 
 
 
April 22, 2009 12:05 AM
Oops! Code hasn't come out very well! I'm sure you can figure it out though :-)

Report
 
 

Answer this Question

How tips and payments work

This question has already been resolved. You may add an answer to it but you will not be eligible to win best answer or any associated tips.

Ask a Question


140 characters left
Top of Page
Buy Mahalo Dollars with Credit Card or PayPal

Top Members

This Week All Time
  • buddawiggi
    buddawiggi
    2nd Degree Black Belt
    27543 Points
    M$789.91 Earned
  • opher
    opher
    Purple Belt
    4443 Points
    M$196.22 Earned
  • annelisle
    annelisle
    Purple Belt
    2997 Points
    M$91.22 Earned
   See All
 

Most Popular Tags

mahalo(1622)
iphone(466)
music(461)
google(358)
food(321)
online(296)
beer(279)
money(262)
movies(258)
apple(251)
aotd(235)
health(220)
video(208)
free(205)
dog(205)
   See All
 

Categories

Welcome New Members


 
 
Mahalo Dollars are the currency of Mahalo Answers.

Each Mahalo Dollar costs $1.

Once you earn more than 40 Mahalo Dollars, you can request to be paid via PayPal. Each Mahalo Dollar is currently worth $0.75 when paid out via PayPal. Learn More

 
 

Please log in to use this function.