Facebook Api: Create Post with image (PHP) - php

I am having troubles understanding the Facebook Api and hopefully someone can help me figuring out how to solve my problem.
What I need: Creating a Facebook Post on a FB Page with an attached Photo.
What I tried:
POST /v2.5/{page-id}/feed
-> I can only add the image as a link
I also tried using
POST /v2.5/{page-id}/photos
and then passed the returned ID to the object_attachment parameter on the previous (feed) API call. This seems to work but it does not look like the same when posting directly on Facebook.
I have an Link "facebook.com" under the Image and when clicking on it it opens the image in the user created Album instead of a Layer. (See attached image)how it looks like
Can someone please tell me how I should proceed to post a message with an image to Facebook so it looks like it was created on FB directly?

Related

Share video on a page on facebook

I want to share a video from my site on a page on facebook, not on my profile.
For Eg: I want to share video on https://www.facebook.com/pages/Opticians/108277472608071
I have a button as post to wall. On clicking it the video should get uploaded on the above mentioned page. I searched a lot for this but I ended in getting only share button which shares the post/video to our profile. How can i share that video on a different page on facebook?
Any Help would be greatly appreciated.
The reference page for this API can be found here. And here is a Facebook Developers blog post related to your problem.
According to this resources Facebook provides graph-video.facebook.com endpoint, that can be used to upload a video to user's wall. You need to perform HTTP POST request to this endpoint passing video file in file POST parameter.

Retrieving fb page info using facebook graph.. not getting picture

I can access facebook page info by going to: https://graph.facebook.com/yorganic.
But the response doesn't contain profile picture.
When i specify the fields to select like the following.. https://graph.facebook.com/yorganic?fields=id,name,picture,were_here_count i can see the picture.
Previously using the first method i was getting the picture but not getting now. Can anyone please tell me whether using the second method is safe or not? and is there any other standard way to do this?
The best you can do is:
First get the Facebook User ID of the user.
Then get the picture with:
https://graph.facebook.com/FACEBOOK_ID/picture
For example: https://graph.facebook.com/100001228933230/picture
EDIT
You don't even need the Facebook ID of the user, you can also use
https://graph.facebook.com/yorganic/picture
You can also use the Graph API Debugger tool for testing:
http://developers.facebook.com/tools/explorer

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

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.

Posting Videos on Facebook using own buttons, similar to share button

I'm working with facebook integration (API) and stuff and I was wondering if it is possible to post videos on facebook using something similar to the Share button.
I know the share button is depreciated, but it still works... but it pops out a dialog box. I'm trying to figure out how to do something like the share button but not have a popout?
I currently have an input field that I can publish to my facebook stream, but would like to see if I can say upload a video with that input field and click on my own created button and publish on the facebook stream?
Does this question make sense?
Thanks in advance!
EDIT:
I guess something like instagram app and the likes where if you post something to their own streaming, on facebook it'll show a photo too.
You have 2 choices.
If you want to actually upload the video to Facebook you may upload it using the PHP graph API, see this link: http://developers.facebook.com/blog/post/493/
Publish a feed to the user wall with data regarding the video.
You can do this by pushing a post request to me/feed and fill in the picture parameter with the thumbnail of the video and a link to it.
see: http://developers.facebook.com/docs/reference/api/user/ - under posts - create

Uploading photo to another user's profile in Facebook using PHP

Can you post a photo to the wall of a friend of the logged-in user using the FB Graph API? I could find no posts that answered this exact question but if there are please point me in the right direction.
I have tried the code found in answers to this question to post a photo, but no matter what user id is used in the call to api, the photo gets added to an album on the logged-in user's profile.
Is it possible to post a photo to another user's profile - just like one any user can manually add to someone's Wall Photos? i.e, a post that will have type: "photo" in the graph API instead of type "link".
Even while going through the old publish documentation, they specify you can only include attachments using links to the media you'd like to attach and not by uploading directly through the API. Looks like this is the route you're going to have to go (using the link property you've already mentioned)

Categories