How to get nationality from Flickr Photo Search Query? - tags

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.

Related

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.

Documentation for CONTAINS() in FQL?

There have recently been several questions posted on Facebook.SO using CONTAINS() in the WHERE clause. It seems to work like the Graph API search function, AND functions as an indexed field. All great things for the FQL developer.
SELECT name,
username,
type
FROM profile
WHERE CONTAINS("Facebook")
However, the only official mention of the CONTAINS function appears in the unified_thread documentation. It is mentioned in passing, as a way to search for text contained in a message. It also appeared in this fbrell code sample.
But Contains doesn't seem to be a straightforward search. For example, this query:
SELECT name
FROM user
WHERE CONTAINS("Joe Biden")
returns "Joe Biden" and also "Joseph Biden" and "Biden Joe". But it also returns "Joe Scardino", "Lindsay Noyan" and "Mehmad Moha" among others. What relationship do these people have with the VP of the USA? They aren't my friends, so I'll never know.
There also appears to be the ability to pass CONTAINS a field to search on, however changing the end of my first query to `CONTAINS("Facebook", name) returns an OAuth error:
(#615) 'name' is not a valid search field for the profile table.
In my not-so rigorous testing, I have yet to find a field/table combination that does not return this error.
So what is this mystery function? How does it work? Can it allow us to do things to date impossible in FQL like traversing arrays and filtering data stored in strings?
An answer here would be great, but a description on an FQL functions & methods reference page on the official developer documentation site would be better still.
I don't think that a have any great answers here, but I can give a workaround for the issue of returning unrelated names- which I suspect is because people have made public posts about Joe Biden, liked him, or so on. If you do the following:
SELECT name
FROM user
WHERE CONTAINS("Joe Biden")
AND strpos(lower(name),lower("Joe Biden")) >=0
You will get a resultset that only contains the right names- though it removes the advantage of also returning Joseph Biden, etc. etc.
My personal point of pain is that CONTAINS() appears to work with partial strings (e.g. "Joe Bide") on the profile table, but not on the user table. Very frustrating.

FQL query,is possible to get all events in your area?

Talking aout Facebook FQL,
is it possible to do a query like
SELECT name, venue, location, start_time FROM event
WHERE location ="New York"
to search all public events, posted on Facebook, and available in your area?
No, since non of fields you listed are indexable
You can however search Graph API for public events in specified time ranges.
Which probably not suitable for your needs, since location field in results still not always contain reliable data, and filtering all the public events in specified range may be overkill...

Use Facebook FQL to select the work information from the profile

I would like to get work place information of a user using FQL.
When I use the Graph API and get the User object, it contains work information, which is essentially a list of the work history. The list elements contain nodes of employer, location, description, etc...
The nodes appear to be pages internally. If I take the id of a node, e.g. from the employer, and use FQL to query a page with that page_id, I do get an object with corresponding information.
My question now is, how do I use FQL to get the same information without accessing the Graph API? What table stores the work-related information, for example how do I find all the page_id of the employers of a given user?
The reason I insist on using FQL only is performance. Of course I could access the Graph API for all the users in question and get the info that way, but I'm looking for an FQL-only solution.
You can get this information from FQL. Read the "user" table and look for the work field. The JSON data returned should be the same format as the one for Graph, i.e., the result is an array and each result should include an "employer" object with an "id" and "name" field.
You will need user_work_history or friends_work_history to access this field.

"sex" field in Users.getInfo in Facebook API

This is a noob question. According to Facebook API documentation, the sex field in Users.getInfo() function returns values based on users' locale. Hence, determine the gender of user is difficult.
Any solution suggested?
1) This isn't an elegant solution, and perhaps there's a better way that uses the API, but what if you manually created a look-up table for different values of 'sex' in different locales? You could try checking out facebook profiles of people from different countries and get the string displayed for their sex. Then, put that into some kind of dictionary data structure that allows you to grab the M-F string pair based on the locale's code (also given by getInfo()). For example en-US => (male, female), ja-JP => (男性, 女性). Of course, you could try using google translate too. After you gathered this data for a handful of the main locales, you'd be more-or-less covered. Maybe someone on the internets already has done it.
Of course, you could try emailing someone who works on the API for these values. The list of locale codes is here http://wiki.developers.facebook.com/index.php/Facebook_Locales .
2) Here is probably a better solution than (1). If you directly query the FQL User table, the value returned in 'sex' will always be English, starting from February 7 2010. More information about that is here: http://wiki.developers.facebook.com/index.php/User_%28FQL%29 . So, perhaps in the future getInfo() will return only English too. Who knows.
3) The answer to your question is also given on this existing post: Facebook FQL user table `sex` field : how to return male/female even the user is using different locale?