I found this code:
$request_url ="https://graph.facebook.com/comments/?ids=" . $purl;
$requests = file_get_contents($request_url);
$fb_response = json_decode($requests);
But I am not finding any official FACEBOOK docs. Is there a better way, or this is the standard facebook way?
Also how do you suggest to implement the database schema?
For example i saw the commment id is something like this: 400711659874_19158387
Should I make an id field of CHAR(21) ?
Thanks
Edit1:
found some doc (a blog post) about crawling fb comments:
http://developers.facebook.com/blog/post/490/
The code sample you're using is functionally correct.
Initially, you'll have to run a script to fetch comments for all the unique URL's on your site which have the FB comments plugin. To refresh that listing periodically, you can later use the 'comment.create' and 'comment.remove' events to trigger an AJAX request which updates the comments for that particular URL in the background.
This is the easiest implementation to grab information from an external resources,
a more industry standard is using curl,
Here is the comparison from one of the old question :-
https://stackoverflow.com/questions/555523/file-get-contents-vs-curl-what-has-better-performance
FB has the login mechanism to prevent unauthorized content grabbing
There are some SDK you can make use.
Also how do you suggest to implement the database schema?
For example i saw the commment id is something like this: 400711659874_19158387
Should I make an id field of CHAR(21) ?
If the comments is tied to your website contents,
you should have a minimum of two columns,
one to store your website contents ID,
one for FB comment ID
varchar(21) is fine, as long can fit the maximum length of the FB comment ID
Related
I know it's super easy to retrieve photos from Instagram according to a specific hashtag from your own profile (with the client id used in the connection to the library), but I could not find anything official to retrieve photos with an hashtag, independently by the users.
So, for instance, if my hashtag was test, an API grabbing a PHP object containing photos as in this link as in the following code
$o_instagram = new Instagram($s_client_id);
$o_media = $o_instagram->searchTags($s_hashtag);
Any ideas or suggestions? Thanks in advance.
have a look at the following endpoint
https://instagram.com/developer/endpoints/tags/#get_tags_media_recent
I'm not sure how it looks in their php library but in ruby is is something along the lines of Instagram_client.tag_recent_media(:tag)
It's paginated in order of most recent first
i want to get profile subscribers(followers) number of some people, and use it at my website.
is it possible to do so without getting an access token?
i already search and found this, and according to this https://developers.facebook.com/docs/graph-api/reference/app/subscriptions/ i must have the user to approve, but i wonder if there is a way to do it anyway, because this number is public.
thanks
Well, if you're able to identify the HTML element in which the number resides, you could just fetch the DOM and look for the element's content.
Here's a plugin example.
That's not working, because you need "user_subscriptions" permission as stated here: https://developers.facebook.com/docs/reference/fql/subscription/
You have a wrong link to the Graph API docs in your question, this is not about app subscriptions (Realtime API) I guess...
I can get a list of comments and likes just fine using the facebook sdk. But i can't
find a way to get a list of all the users that shared a post (i tried fql as well).
This is the code i used to get the likes:
$facebook = new Facebook($config);
$likes = $facebook->api('/THE_POST_ID/likes',
array('limit'=>9999999999));
At the time of writing this, Facebook Graph API allows you to get the count of shares of a post. Using your code, it would look like the following (please not that I'm not doing any exception handling here for keeping the example simple):
$facebook = new Facebook($config);
// fetch the post data.
$post = $facebook->api('/THE_POST_ID/');
// fetch the count of shares.
$sharesCount = $post["shares"]["count"];
Using the Graph API Explorer you can easily see that.
Unfortunately, the API does not provide a "shares" connection like it does for "likes" and "comments". See Post - Facebook Graph API Documentation for details.
On the other hand, there is a dirty hack for retrieving the list of users (only friends and people who shared publicly) who shared a specific post. The solution is explained on another thread: List of people who shared on facebook. But, I would never suggest using that solution.
Yes you can get list of all the shares of a facebook post.
by accessing:
https://graph.facebook.com/{POST_ID}/sharedposts?access_token={ACCESS_TOKEN}
See:
https://developers.facebook.com/docs/graph-api/reference/v2.5/post
I know you're looking to get at shares through the post_id, but can you settle for finding shares by page_id instead of post_id?
If you can, then you can use the following FQL to get the data you're looking for.
SELECT via_id, created_time, owner_comment
FROM link
WHERE owner = me()
You can then compare via_id against the posts author (page ID) to determine if this share came from the post author in question.
Unfortunately, there seems to be a bug with the data return where some of the via_ids come back as 0. There is a ticket in with Facebook which, at the time of this post, has been open for three weeks at medium priority. I have no idea if this issue is specific to my app or affects everyone, but that query might get you what you want.
I want to update a no_comments row in a database exactly when a facebook comment on my site is made. I would like to do the same thing for likes as well.
I can imagine setting up a cron job that uses the graph API to periodically retrieve the number of comments and likes and update the database but for a large number of objects that are associated with comments the lag introduced is undesirable.
I am not looking for someone to "code a solution" for me...rather can someone point me in the right direction: is it possible to use AJAX to somehow update the database at the point when a comment is made or a like is done?
I can see how one can use the click event for the like button but it's not fool proof...
All help is appreciated!
Assuming you are using Oauth and have a facebook application then I would consult the facebook API docs for events or triggers. If a method exists it will be in the API docs.
Your description of your "site" is vague so it is hard to understand what your site or how it connects to facebook.
Edit:
I wish people would explain down votes. I can't fix it if I don't know what the issue was.
I followed my own advice and searched for this "facebook run script when like is clicked" on Google and found this: enter link description here This is almost the same question except it deals with "like" buttons rather than comments.
You can generate "events" like I had previously suggested. So further consultation of the FB API may be the most fruitful way of finding out if there are events around "comments" as well as "likes".
Maybe the OP knows this, but there are several APIs (last time I checked) to facebook including Javascript methods that could be used in an Ajax manner. However, without further details of their website implementation there is no way to tell.
i am working on a project in php.
When we post something on twitter, i want to grab the users who have re-tweeted my tweet and store it in my database. I want to work in php and mysql.
If I post a question on my tweet, i want grab the answers and save the userinfo of all the users who gave the right answer.
Any suggestions on how to get started?? Thanks :)
Here is a full twitter API class that someone has built that might be useful as well.
http://brandontreb.com/the-only-twitter-api-php-class-you-will-ever-need/
UPDATED:
Here is a RESTful API service for pulling retweets of your items:
http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-retweets
You can use a pre-existing class or build your own. It will most likely require cURL and XML knowledge. But if you understand PHP, you should be able to knock this out fairly quick.