Can't get Facebook comments from my post to the website - php

I am trying to show the comments from my facebook page post on my PHP website. I like the comments to be synced, so where the user enters comments on the facebook post of my page, it will automatically show up on my website. I know how to create the comment box, but it's doesn't pull the comments from the page.
for the comment box I have:
<div class='fb-comments' data-href='https://www.facebook.com/media/set/?set=a.182291248558753.39531.182290545225490&type=1&l=d607ba4dcc' data-num-posts='3' data-width='470'></div>
I am trying to show the comments that were left on my post, but it's not pulling it. I have looked at the graph API but can't figure out which on get the comments and how to get the so called "primary key" for the comments.
I have looked at the following fql:
Stream: but I don't know what the "post_id" is supposed to be. https://developers.facebook.com/docs/reference/fql/stream/
Comment: but I don't know what the "post_id","object_id", or "xid" would be for a post in a page of the an album. I even tried to replace the URL in the example post they had, but it seems like FB FQL can't parse that kinda url. https://developers.facebook.com/docs/reference/fql/comment/
Even when we get a list of comments, I am not sure how the fb:comments plugin can use the stream to populate my page, don't know if it's possible!
Any help would be greatly appreciated.

You could use Facebook PHP SDK for this which you can get from github. You can then use it to retrieve the comments from the post and store them in a database, updating every now and then to stay current. This will mean less requests to Facebook. When a user posts on your site using your form you can then send the post to Facebook using the SDK.
The problem with this method is that you will need to create an app and users will have to authorise the app for it to be able to post as them. So maybe it's not such a good idea, but I've typed all this in now so I'm not going to delete it.

Related

How to managed facebook post in own database for better manipulation?

Imagine I want to store in my database the facebook posts from a user/page for getting them and manipulate them simplier.
I will make a php script that will be launch every day for each user/page who will get the posts I don't already have in my database and insert them.
Now, on my front website, you can log in, and see your posts.
Now, you go on facebook, and modify one of your post.
Now you come again on my website, and obviously, you don't see the modification you did on facebook, because this modification is on facebook database and not in mine, and your posts a retrived from my Database.
Theorically, one of the solution will be that facebook has a "log" table for posts, where i can find something like "this posts has be updated" so i can update my table. Something like that exist ?
If not i have a second solution, at each posts send from my server to my website, update it automatically with facebook database (getById the post on fb an update it in my db) and after that send the posts to my website. But this will be a mess and a lot of request for nothing.
So how can i do this ? Someone have already tried this ? Or only directly manage the posts from facebook database ?
Thanks =)
Facebook has a mechanism to send updates to you, called webhooks.
https://developers.facebook.com/docs/graph-api/webhooks
You can subscribe to several fields for users or pages, among them the feed.
You’ll have to check if it delivers updates to already existing posts as well - but I think it should, would make little sense if it didn’t.

Using graph api to bulk upload to facebook company page (not a user page)

I found this, but it is kinda confusing, and doesn't answer the question for me. I'm looking to upload images from my website to a Facebook page (my code works for users pages, not company pages), if there is a way to do it without having to make an application, I'd like that, but from what I've seen, that's not possible.
My code is here: http://pastebin.com/wBp1AQwG
Your link doesn't appear to go anywhere useful, I'm afraid.
Nonetheless, I'm guessing your problem here is that you need to use a Page access token not a user access token to publish to a page rather than a user feed.
See the section on Page Access Tokens at https://developers.facebook.com/docs/reference/api/page/
I've figured it out, here is a basic outline of the process for posting an image to an album that you own on a fanpage.
Get user authenticated
Get users accounts
Get albums, or create them
Post to the id of the album (ALBUM_ID/photos) with the image
It's pretty simple once I figured out the basics of the api.

Why do geotargeted posts not appear in API even with accesstoken?

This has been asked before but I haven't seen a definitive answer. Hopefully someone has an answer. Basically, it seems impossible to pull any post that is geo-tageted via the API becasue it has privacy settings, that is, a country set to who can see it.
I am using https://graph.facebook.com/".$pagetoprocess."/posts?&access_token=".$att and this will pull the posts but not any posts that are geotargeted to the UK for example.
If I create an accesstoken from a user who is an admin of the page then I see all posts including geotargeted posts.
Why would this be? how can I see all posts for any page whether I am an admin or not or whether it is geo-targeted?
I would have thought that if you creaded an app in the UK and therefore had an app and secret id code from which you then generated a user access token, why would you not be able to see a post from a page geo-targeting the UK? Seems strange.
Any ideas?
Thanks
Jonathan
I would think that all posts would appear, or at least that is what it says on the api. You could try using feed instead of posts, since posts is a derivative. You might also try using:
&include_hidden=TRUE
But I'm not sure that will help.
If you have the page url, I'd be willing to see if I can play around with it in the graph explorer.

Application able to post on user's Wall

I have a Fan Page and I need to post something on users Wall after clicking Like Button. Moreover I need to display different content for users who "Like" the page and for users who don't "Like" the page. Is there an application like "Static iFrame Tab" which already solves this? If not, then how to post something on users Wall? I downloaded the facebook.php file, but I haven't managed to find the required function there.
The user's 'like' status can relatively easily be returned by decoding the signed request sent by Facebook to the page.
I've built a simple fan/like gate that is available over on GitHub - it might help you get up and running.
With regards to posting to the user's wall. I would suggest using the Javascript SDK and reading the FB.ui documentation over on Facebook.

search for comments on a page posted with facebook api

I have a testing page on my site that simply lets users login. Once logged in, you can post a comment on the page (testpage.php). I am able to get the graph of the posted comments, but how do I search through those comments. I want to make a page where anyone can search through comments on testpage.php and all comments that match what was searched for would appear. how would I go about doing this? I have already looked over the facebook developement pages but they do not go into the details I need. Any ideas?
Referring to the Graph API page, https://developers.facebook.com/docs/reference/api/ (look for the Searching section) you cannot use the API to search for comments directly. You would have to get all the posts using the Graph API then perform your search separately.

Categories