Facebook FQL : how to get album's location ID? - facebook-fql

When getting information about album, I can get only location name :
select aid, owner, location from album;
But I need also a place ID for further manipulations.
I can't just query "place" table to return me places that have the name of album location ("name" column is not unique and not indexed in place table).
How can I get that place ID?

The user can put anything they like into this field – so the info you’re getting from there does not necessarily have to correspond to any specific place on Facebook.
For example, I could name my album “Photos from my Holidays in 2012”, and type “New York, London, Berlin, Tokyo” into the field – so you can not expect the API to return a specific location id in those cases.

Found it. It can be taken from a "photo" table, when getting a photo associated with that album:
select aid, place_id from photo where pid = (select cover_pid from album where aid = you_post_attachment_fb_object_id)

This is don't work in 100% cases. Because album can be empty or locations of album/cover photo can be different.

Related

How to get nationality from Flickr Photo Search Query?

I am extracting some metadata from FLICKR PHOTO SEARCH. I have now constructed a query, which pretty much does what I want: https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=.....&text=yes&bbox=....&has_geo=1&extras=geo%2C+description&per_page=500&format=json&nojsoncallback=1&api_sig=...
I have 2 questions:
Is there any argument that provides me information on the nationality of the Flickr user?
How to modify the arguments in order to include "Tags" to the query?
thanks,
A.
Per flickr.photos.search, add &tags= to your URL query string to search by tag.
Given a photo, you can use flickr.photos.getInfo to determine the user (the owner attribute), and from there you can use flickr.people.getInfo to get the user's location. That's not the same thing as nationality, of course, but you may find that info sufficient.

Public search facebook user by Non-exact name

I want to do a public search on all facebook users according to the name of the user, but i want the search not to be on the exact name. for exmaple if a user will search for 'John Ada' the result 'John Adam' will be retreived too.
After that the results need to be ordered by mutual_friend_count.
I manged to do this partly with the following FQL :
SELECT uid,name, pic_square, profile_url , mutual_friend_count FROM user WHERE contains("Name Surename")
order by mutual_friend_count desc
but it returns only exact names, and if the name was missing a letter like my earlier example the user was not retreived.
I tried to mess around with the Offset and Limit but with no success either.
Thanks!
The Facebook search algorithms seem to be optimized to find full names. A partial name never seems to return as many results as a full name will. In my experience, Facebook knows how to expand names for common variants. A search for "John Adam" will return "John Adams", "Johnny Adams" and "John Addams"
The other battle you are fighting is the Facebook filtering algorithm. Facebook first finds all matches that meet your query, then filters them for visibility to your user.
You can try adding AND NOT is_blocked to your WHERE statement. This should filter out anything that isn't visible to you before the filtering algorithm.

getting latest photos from friends not working

I tried getting the latest photos fo my friends using a method described here:
FQL - Can i get photos of my friends posted this week
At first it seemed to be working fine but then I noticed that some of the photos of my friends weren't being fetched even though they had a higher timestamp (the photos were being sorted by created field from photo FQL table)...
After a bit of debugging I noticed that the problem is in
SELECT aid FROM album WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1=me()
if I pass a short list of my friends' IDs they are being sorted correctly, but when I pass a complete list not all friends are included in the query result...
Any ideas why this isn't working? Are there any limits on how many values can be passed in a "SELECT XXX FROM YYY WHERE ZZZ IN (?)" query?
Thanks in advance for any advice
The limit seems to be about 5000 records returned in any part of an FQL query.
Assuming you have fewer than 5000 friends, you could cut down on the number of albums returned by modifying your query to inspect the modified_major column to only return albums that have had a photo added in the period of interest. You could alternately look at the modified column to return any album modifications.
Also, it looks like aid and pid are on the path to deprecation. New development should use object_id for maximum compatibility.
So to get all albums that have had a photo updated since 2012-10-01, you could use this query:
SELECT object_id FROM album WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1=me()) AND modified_major > 1349049600
In your outter query change aid to album_object_id and pid to object_id

How can I get pic_squre and sex from user id's I already have

I am creating an application in which user can select 10 friends of the user to tag.
I can get those selected 10 friends uids into an array, like:
xyz[0]=1234567
xyz[1]=5364753
What is the FQL query to select pic_squarw and uid where the user id is id in the array, xyz[].
$data->sex http://graph.facebook.com/zuck
cropped picture http://graph.facebook.com/zuck/picture

How to filter by category in FQL

As you can see here,
Businesses have their category information: Local Business, Sport, Education.. etc. It is the field "category".
I would like to know, is there a way to filter businesses by their category and position with FQL? I haven't found how to do it. For instance: give me all the sports center in this circle (lat, lon, radius).
thanks
The "category" attribute in the "page" table is called "type". Here is a query to filter the logged-in user's "local business" likes:
SELECT page_id, name, description, type, pic, fan_count
FROM page
WHERE
page_id IN (SELECT page_id FROM page_fan WHERE uid = me())
AND Type = 'LOCAL BUSINESS'
Run Example
You can't retrieve pages by category.
The FQL Page table has a field called categories.
You can retrieve the category for a business with FQL like this:
SELECT categories FROM page WHERE page_id = PAGE_ID
where PAGE_ID is the page's Facebook id.
However, categories is not an indexable field. You can't ask for all business in New York which are Florists since "WHERE categories = florist" isn't allowed.
I have been looking for something and haven't found anything. It appears that only the graph api has the category information for a page.