Next Question

Mahalo is adding a tip to all questions that don't offer a tip.
M$2.00 Funded By Mahalo ? |
April 21, 2009 07:13 PM
RSS
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
Permalink | Report
warlrus
Answered Question

Mahalo is adding a tip to all questions that don't offer a tip.
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)
- In Programming |
- |
- Report |
-
Share
RSS
Best Answer Chosen by Asker
| April 22, 2009 12:04 AM |
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: |
Permalink | Report
warlrus
April 22, 2009 12:05 AM
Oops! Code hasn't come out very well! I'm sure you can figure it out though :-)
Tip warlrus for this comment
Report
Answer this Question
Related Questions
Ask a Question
Buy Mahalo Dollars with Credit Card or PayPal
Top Members
Most Popular Tags
Categories
- Anonymous
- Arts & Design
- Beauty & Style
- Books & Authors
- Business
- Cars & Transportation
- Consumer Electronics
- Coupons Deals
- Education
- Entertainment
- Environment
- Fitness
- Food & Drink
- From Email
- From Iphone
- From Twitter
- Health
- History
- Hobbies
- Home & Garden
- How Tos
- Humor
- Jobs
- Legal
- Local
- Love & Relationships
- Mahalo Answers Community
- Money
- Music
- News
- NSFW
- Parenting
- Pets
- Science & Mathematics
- Services
- Shopping
- Social Science
- Society & Culture
- Sports
- Technology & Internet
- Travel
- Video Games
Welcome New Members
- hollyjahangiri, November 29, 2009 08:35 PM
- tab_101, November 29, 2009 08:31 PM
- mariabou, November 29, 2009 08:30 PM
- efm, November 29, 2009 08:29 PM
- bencurtis, November 29, 2009 08:29 PM
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