PHP Graph API to disolay photo from album - php

I wrote a php script that gets random articles from my DB and display it on my Facebook page using the graph API, I was about to do the same with the images that I want to post but I noticed that it won't be efficient because getting the images in random will mean that the same image might be uploaded more than once in more than one occasion
The efficient way would be uploading all the images to a Facebook album instead of the DB and then use the graph API to post the images from the album the problem now is that I can't figure how to do so.

You can move the images you have already uploaded,
otherwise, mark the rows you've already uploaded to facebook and exclude these rows from your select query.

Related

Concerning the post picture size of facebook page/group feed by Graph Api

I am displaying feed/posts of facebook page/group via graph api in my site by calling this Url in php code -
https://graph.facebook.com/page_id/feed?access_token=token_value
Then, Among many type of posts, for a post of picture type i get picture url as
http://photos-g.ak.fbcdn.net/hphotos-ak-frc3/t1.0-0/1972372_10152261154160659_883879121_s.jpg
Now it's the small size as the last part "_s.jpg" indicates.But i want all picture sizes be large.So to achieve this what parameters are needed to include in the graph api url - "https://graph.facebook.com/page_id/feed?access_token=token_value" so that all picture/video type of posts' picture will be in large size??, so is there will be "_b.jpg" at last as i presume.Is that possible in one graph api call?
I searched through the google but no luck, but ended up planning that i would replace the last part of the pic url above with "_b.jpg" so that url will be like -
http://photos-g.ak.fbcdn.net/hphotos-ak-frc3/t1.0-0/1972372_10152261154160659_883879121_b.jpg
But are there any drawbacks for this hack?? what are the correct ways to achieve if possible in one graph api call.
notice,
/page/feed?fields=attachments
this will give you all of the attachments in their full sizes. worked charms for me
You could use a FQL query to get the source info of the large versions of the photos use in a Page's feed:
SELECT pid, object_id, src_big, src_big_width, src_big_height FROM photo WHERE object_id in (SELECT attachment.media.photo.fbid FROM stream WHERE source_id={page_id} AND actor_id={page_id})
Not sure if that’s actually documented somewhere – but in Graph API Explorer, the “Search for a field” feature suggests a field called full_picture. A few quick tests suggest that for most feed items, it returns the original image that was used making the post, whether it was a picture uploaded with the post, a video thumbnail or whatever.
You can use it in your feed calls like this:
/{user-or-page-id}/feed?fields=full_picture,message,type,…
Only fields you will get by default when using the fields parameter are id and created_time, everything else you might be interested in (message, type, from, etc.) you will have to ask for specifically as well.
That is for any type of feed item that might have a picture attached – expect for type:photo. For those, you get an object_id as well, and when you query that explicitly in a second request, you get an images data structure, that lists the different image sizes Facebook has on their CDN.
I have not found a wya to make it spit out that additional info within the original /foo/feed request in one go though – but if you collect all object_id that call delivers, you can use them in a second call like this to get the info for multiple objects at once:
/?ids=object_id1,object_id2,…&fields=images
with every feed there is a node name object-Id, use this id like this
graph.facebook.com/object-id/picture?type=large
if it shows question mark photo then use access_token=XXXXXX in query string.

Create the "Timeline Photos" album using Facebook Graph API

What I Want
I need to create the posts on a page wall with a big preview pictures - like the ones that are displayed when you upload a photo. It will make sense to add those photos to the "Timeline Photos" album of a user (or page) using the Facebook Graph API.
Sure I can poll the users albums list and search for a type:"wall" one (i.e. the Timeline Photos in the English translation), but what if the album does not exist? How do I create one or how do I make Facebook Graph create it?
What Have I Tried
Tried posting to /me/feed with a message and a picture URL (params picture or source), but all it does is just create a type:"link" post with a small picture, while what I need is a type:"photo" one.
Once again, I need that because of the big photo that gets displayed on a wall if post is a photo. For instance, that happens when I upload a picture to the album that gets automatically created for my application. But the issue is that when there are several photos posted one after another, Facebook automatically groups them in a set that belongs to an album.
P.S.
Basically, what I want to achieve is having an ability to send the posts to a page wall with big preview photos on the wall itself that are not grouped by an album name.
Please help. Thanks
Solved by posting a photo to /{page-id}/photos.
https://developers.facebook.com/docs/graph-api/reference/v2.0/page/photos

Adding facebook profile picture to high scores table using PHP

I was able to make a small flash game after receiving a lot of help here at Stackoverflow, I was able to post the score variable to a php file and then to database , now I would like to make a small high score list and I know I would need to use the FB users and scores previously saved to the database’s table, my question is how could I add the profile picture thumbnail besides each user’s score ? Should I save another parameter to the database or should I use the following line when I print the databse info in the html file ?
<img src="https://graph.facebook.com/<USER_ID>/picture"/>
I’m really sorry if this is a silly question, I’m really inexperienced with facebook stuff. Thanks!
This is indeed the best way to display profile photos of your users (or any users). There is no need to store URL's or even download the images to your server. All you need is the users Facebook ID.
If the pictures are those of the users friends, the chances are that they already have those images cached in their browser so it's a good idea to take advantage of that.
You can also add some parameters to that call to get other sizes of the profile picture -
https://graph.facebook.com/UID/picture?type=large
The values that are accepted are -
small
normal
large
square

Facebook and image post

I want to post into community wall post with attached image. If I use simple api call to /page/feed with picture arguments it inserts a small image. But I want to attach big image, for example, from gallery. When I upload photo to gallery it automatically posts to wall. But when I post >= 3 photos all that posts are merged into single one with all inserted images.
The question is how to get different post for each uploaded image? Or maybe I can attach to /page/feed api not picture only, but image which would be uploaded into album?
Thanks
When you say "attach big image", I assume you are POSTing to /PAGE_ID/photos, right?
If you upload 3 or more images, yes, they will be collapsed when they are displayed in the page's feed. This is a "feature" of feed that organizes and collapses images that were uploaded together.
Imagine if you uploaded 20 photos to the page and they weren't collapsed; the feed would be dominated by the photos and it would be hard to see any other content (like content that was published slightly before the uploaded photos).
If you can provide a screenshot of what you are seeing, I can confirm this.
And yes /PAGE_ID/feed with picture is a thumbnail for a post. Example: a thumbnail to accompany a post containing a paragraph of text (or a link).
https://developers.facebook.com/docs/reference/api/page/

Flickr API PHP getPhotoSets Description

I'm trying to integrate the Flickr API with Jquery Gallerific. If you're familiar with Gallerific you know photos in the Gallery can have a caption. I'm trying to pull photos from a specific set from a user using flickr.photosets.getPhotos to get thumbnails. However, with this method it's not possible to get description for each thumbnail, only for the set so I'm having to run flickr.photos.getInfo for each photo in the set, which works but is pretty much useless as a page takes 10+ seconds to load. Does anyone know how to obtain flickr photos from a set with the individual description for each photo? I've looked through the API but can't seem to find anything.
Thanks in advance!
Never actually used the Flickr API but what about just loading the thumbnails initially, then using JSONP (or a custom "proxy" of sorts) to query photo information asynchronously after the page has loaded. Or, better yet, when the user actually hovers over an image.

Categories