Caitlin-havener Posted March 5, 2011 Share Posted March 5, 2011 I am trying to make a little business webpage that I am inventing here. I want to be able to countdown the number of 'likes' needed before I post a new product for sale on the site. What I need to know how to do is get the number of 'likes' that are on the business facebook (http://www.facebook.com/pages/MyBambinoBargains/199400810089656) and store that in a variable for use. Later I will make a function $likes=(some way to get this from facebook!);$likes_wanted=350;$likes_total=$likes + $likes_wanted;$likes_left=$likes_total-$likes;print "$likes_left likes left before the next bambino bargain is available!"; Link to comment Share on other sites More sharing options...
birbal Posted March 5, 2011 Share Posted March 5, 2011 though you question is not clear here.. btw it will always give you the 350 like lefts....if i am not missunderstanding your issue...the only like_wanted=350;like_left=like_wanted-likeswould be appropiate.. Link to comment Share on other sites More sharing options...
Synook Posted March 5, 2011 Share Posted March 5, 2011 Birbal, she wants to retrieve the number of likes a page has from Facebook.Have you looked at the relevant section of the Facebook Graph API: https://developers.facebook.com/docs/reference/api/page/? Link to comment Share on other sites More sharing options...
Caitlin-havener Posted March 5, 2011 Author Share Posted March 5, 2011 Okay I'm reading up on it now. Looks like the following contains the number of likes on my page: https://graph.facebook.com/199400810089656. How would I put that number into a variable? Link to comment Share on other sites More sharing options...
thescientist Posted March 5, 2011 Share Posted March 5, 2011 you would probably want to use something like cURL, which allows you to retrieve pages across domains. http://php.net/manual/en/book.curl.phpa simple example might look like this: <?php$session = curl_init(https://graph.facebook.com/199400810089656);curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false ); //i believe is needed for HTTPS calls$returnedContents = curl_exec($session);curl_close($session);var_dump($returnedContents);?> another alternative is to just add a FB like button right to your page. It's just a copy/paste, stylable piece of javascript and will show the amount of likes associated with the url. http://developers.facebook.com/docs/reference/plugins/like/ Link to comment Share on other sites More sharing options...
Caitlin-havener Posted March 5, 2011 Author Share Posted March 5, 2011 Thanks, I'll save the link to this post. I decided to put this project on the backburner and get my portfolio going Do you know anything about freelancing and web design home business? Link to comment Share on other sites More sharing options...
thescientist Posted March 5, 2011 Share Posted March 5, 2011 sure. you an PM or we can chat with any question you have or you can make a thread about it. I have a FT job in the field, but I started off on my own, and am currently active with my own clients and personal projects, and projects for my friends. I'm (and everyone here is) always happy to share knowledge. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.