Embedding Facebook photo albums with like button, on my website - facebook

Can I do something like this?
I want to have all the photos from my fan page, embedded on my website.
Want to have the option to like each photo - must.
Want that each photo will have a link to the real URL on Facebook - must.
Would like to share and comment as well but not as important.
Please let me know if you have an idea of how I can do it.
I saw a lot of examples but nothing that include these things.
Thanks!

Getting some of the photos is easy. Getting all of the photos is nearly impossible. Start with a Graph API call to the photos object.
To get the photos, create and app, install the PHP SDK on your site. This code should get you started.
$config = array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
);
if (!class_exists('Facebook'))
include_once 'PATH_TO_SDK/facebook.php';
$fb_object = new Facebook($config);
$photos = $fb_object->api('PAGE_ID_OR_USERNAME/photos', 'GET');
printf('<pre>%s</pre>', print_r($photos, true));
You'll need to iterate through these results to get more than 15 of your photos. Photos that aren't marked as "Public" won't be returned by this API call.
To create a like or a comment, you need to auth the user and then POST to the Graph API using the photo id.

Related

How to access images that already uploaded through our own facebook application using facebook php SDK?

I'm having an problem when I want to retrieve all the photos that already uploaded by users using my faceboook web app. Usually I'm doing this to access my application album with facebook php SDK
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'SECRET_ID',
'cookie' => true
));
$app_name = "My Own App";
$jsonalbum = $facebook->api("/USER_ID/albums?fields=id,name")
$album_id = searchAlbum($app_name." Photos", $jsonalbum)
I have to doing this with every user that having permission to my app, It's a little bit awful. I just want to ask, is there any ways to retrieve all images based on app that upload it before?
I do not believe that there is a way to do exactly what you are asking.
The correct method would be to record all of the images that were uploaded (at the time they were uploaded) and storing their ID's in a database of sorts.
Facebook doesn't really allow users to mine data - as you are requesting. Users are are an entity in and within itself - the fact that the image was uploaded via your application doesn't really come into play here. Once the image has been uploaded it belongs to the user and not to your application.
Perhaps if your images were all uploaded to an album created by your application you'll be able to just request the contents of that album - but if the users have since moved the image to a different album - you won't be able to see that it has been moved.

Upload image to facebook fan page using Graph API

I am trying to upload an image through my application with Facebook Graph API to an album of my fan page. Although I provide the albumID like a parameter for uploading the image, it is uploaded in an album named to my application name Photos on my own profile. The album of the fan page stays empty. I tried also with sending the pageID of my fan page instead of albumID, but the result is the same.
I thought there is a problem with access token but with same accessstoken i can post links to page.
The code I use for the upload is:
$args = array(
'access_token' => $access_token,
'message' => "$baslik",
"source" => '#' . realpath($file)
);
$post_id = $facebook->api("/$page_id/photos","post",$args);
Please give me ideas how can I upload the image to the fan page and not to my own profile album.
I think you havent got Manage Permission.
Check this for more info : Upload image to facebook fan page using API

Upload image to Facebook Wall / Feed via Graph API

I am trying to upload local images directly to a pages feed (i.e. "Wall Photos" album).
This is the code that I think should work:
<?php
$facebook = new Facebook(array(
'appId' => $the_app_id,
'secret' => $this_app_secret,
));
$facebook->setAccessToken($the_access_token);
$facebook->setFileUploadSupport(true);
$attachment = array(
'message' => $the_post_body,
'name' => $this_image_name,
'picture' => '#' . $the_absolute_path_to_image
);
$result = $facebook->api('/me/feed, 'post', $attachment);
But this code just yields a plain text wall post with the contents of "message" (i.e. picture field is seemingly ignored). I have also tried "/page_id/feed", same result.
Now, simply changing the endpoint to "/me/photos", does upload the photo to a 'normal' album with the name of the app, but I want it to look as much like a normal post as possible and so hence into the "Wall Photos" album).
I realise that I could achieve this by querying the graph with FQL to find the object_id of the "Wall Photos" album, but if it does not exist it would require extra permissions to create it and I would rather keep permissions as simple as possible.
If anyone could point out how to upload photos to "/me/feed" I would greatly appreciate it.
But this code just yields a plain text wall post with the contents of
"message" (i.e. picture field is seemingly ignored). I have also tried
"/page_id/feed", same result.
You can only give the link to picture but not the data.
Now, simply changing the endpoint to "/me/photos", does upload the
photo to a 'normal' album with the name of the app, but I want it to
look as much like a normal post as possible and so hence into the
"Wall Photos" album).
Ye, it creates an album by default based on app. if already exists, it uploads to album. And generates a post.
I realise that I could achieve this by querying the graph with FQL to
find the object_id of the "Wall Photos" album, but if it does not
exist it would require extra permissions to create it and I would
rather keep permissions as simple as possible.
You cannot upload to fb for me/feed end point. You should store in your server/s3/some service and give the public url to me/feed params.

Suppress Facebook timeline* update when adding images to an album

I am working on an app that creates albums in Facebook and then adds photos to the album. That side of things is working fine.
When the photos are added to the album facebook puts on the users timeline* something like " has added new photos to the album ."
What I would like to do is suppress this message, or at least customize it a little.
Does anyone know if this possible with the Facebook API? I have not been able to find anything in their doco, and suspect it is a automated thing that facebook doesn't give control over, but would like to get confirmation.
Cheers!
*not 100% sure if this is strictly the "timeline" or just their wall.
Use the no_story = 1 parameter.
$newphotodata = array(
'access_token' => $fanPageAccessToken,
'message' => $message,
'no_story' => 1,
'aid' => $albumId,
'image' => '#' . $picturePath);
$uploadedphoto = $facebook->api('/' . $albumId . '/photos/', 'post', $newphotodata);
I am working on this topic myself at the moment. This is my latest on it: http://facebookanswers.co.uk/?p=322
Incidently, have you worked out a way to generate a proper timeline post when you create a new album. If you do it manually, you get a nice post showing four of the images. But if you use the API you cannot get that. You can nearly get it by posting to /links/ but its still not quite right, as friends will just see a single icon.
Well, looking at the facebook api I can find no mention of how to suppress these automated status updates. From this I have concluded that it is not possible to modify or suppress these status updates.
Thinking about it some more I can understand why facebook would not these messages suppressed or changed as it could be abused by apps to make posts without a user noticing.
Just close the window after uploading and open again IE.

Get Facebook Page Wall Stream

I want to get the posts (only from the band, not others) from a Facebook Page Wall (its a Band, so no private profile) and publish it on MY own site.
I hoped to get the Posts as XML or JSON and then parse them.
So I wanted to use Facebook as a news System.
But I didn't find a solution - I don't want to have the user to log in with his account to see anything - it should be just a public stream.
The only idea I found was to use twitter as an export mechanism, but that's kind of elaborate.
Does anybody have an idea?
You could use the Facebook php sdk: https://github.com/facebook/facebook-php-sdk
It ends up looking like this:
//
include('facebook.php');
$fb_config = array(
'appId' => $yourAppId,
'secret' => $yourSecret,
);
$facebook = new Facebook($fb_config);
$feed = $facebook->api("/{$nameOfFaceBookPage}/feed");
That will give you an array of feed stories.
I assume you created a facebook page for your band and it has url in such format:
http://www.facebook.com/pages/<band_name>/<page_id>
In this case you can read wall posts in json format using Graph API (no login required):
https://graph.facebook.com/<page_id>/feed
If you only want posts from "me", can't you just use the Like Box social plugin and show the stream? This plugin will only show posts from the page owner.
http://developers.facebook.com/docs/reference/plugins/like-box
I am developing a similar app and after a lot of searching finally accomplished
https://graph.facebook.com/194466683916784/feed?access_token=AAACTzPZAxblQBAHND7fo1rA58VqQawuJb806Q6BeIFhTroyGSYIe5i0R5fZAZBtffNvkkZB7ayvV7Vw7j7ZBf7vGt6xHx2gjx4FhO8d27sAZDZD
enter your page wall id after .com and in the access token get your own access token from Graph - API explorer
Then exchange that token for a longer for a longer lived one that is for 60 days and you are good to go
Some time ago I had your same problem and I was looking for something very simple to publish feeds of facebook pages, but I didn’t find any solution on the web.
What I want to achieve are the post (only from my personal fan page, not the other) of the bulletin board (facebook wall) of a FB page (this is a fan page, not private profiles) and publish it on my site.
I was hoping to get the posts in JSON or XML format and then encode them so as to use FB as a news system. Unfortunately I haven’t found any kind of solution because I don’t want the user has to log in his account to see something so it must be a flow of pubblic feed.
So, I decided to code the plugin. Here the link to the tutorial:
http://www.lorenzodedonato.com/freebies/facebook-plugin-per-visualizzare-i-post-della-bacheca-di-una-pagina-fan-creato-in-php-json/