How to get exact phrase match out of Graph API search - facebook

Looking for a way to get an exact phrase match out of the Graph API's search endpoint. For example, all activities with "dogs and cats" in them. Putting the phrase in quotes doesn't seem to work, the API will return activities containing those words, but in any order.
curl -v "https://graph.facebook.com/search?q=%22dogs%20and%20cats%22&type=post&limit=75&access_token=&since=Wed+Jan+25+20%3A59%3A30&until=Wed+Jan+25+20%3A59%3A40"
returns and activity whose text is:
"Ohhh man it's raining dogs cats lobsters crab birds and horses up here. I'm scared!"
"dogs" "cats" and "and" are all in that post, but not in order.

Yeah I faced the same problem. There's a similar question that might help Using the Facebook Graph API to search for an exact string
Facebook doesnt allow exact phrasal matching drectly, atleast not at the API level, You would have to fetch the entire data and programmically check for exact matches (too slow though).

Related

Facebook Graph API - Searching in public posts

Is there a way to search for 2 keywords in a public post? I want to do a full text search in all public posts.
Right now I am doing it as "https://graph.facebook.com/search?q=A+B&type=post&fields=link,message&access_token=<>.
Current Behavior: fetching posts having A or B.
Required Behavior: Fetch post have both A & B.
I have also tried POST method in Graph API Explorer. Please suggest what should I do to get results.
Other things I tried :
facebook graph api search rules. But it also seems not working, even when I tried with q=A&q=B. Only second query word is getting searched.
Use the '|' operator. In your note, 'q=A&q=B' you are reassigning the value of 'q'. The API parses the string set as the value for 'q' and uses the '|' operator to parse between. Either way you will have a tough time finding a lot of results because the 'search/post' API is now deprecated.

How to get multiple adrresses from GoogleGeocoding API?

I want to retrieve all the address locations (latitude,longitude,format address) for a single 'search address' request (a little vague such as "Tata Consultancy Services") in MapKit.
I searched on the net and came across GoogleMapsAPI WebServices .
http://code.google.com/apis/maps/documentation/geocoding/
But problem with response is that, it returns only a 'single object' in 'results array' response for a address search.
As an example if you search "Tata Consultancy Services" you get only one location whose formatted address is "TCS Rajshree Business Park, Tadiwala Rd, Sangamvadi, Pune, Maharashtra, India".My question is how can i get details of other locations as we all know that this is not the only office of TCS.
I would like to quote two documentation links related to your problem.
http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests
"Generally, only one entry in the "results" array is returned for address lookups, though the geocoder may return several results when address queries are ambiguous".
So you may found one or more result. but as you are requesting it from iPhone and sensor is by default true. you receive nearest matching result for your query.
The solution is "Viewport Biasing".Please find its details at below link under heading name "Viewport Biasing":-
http://code.google.com/apis/maps/documentation/geocoding/#Viewports
Another options you can try on:
try setting sensor as false.
try region biasing as described on the same page cited above.
try some other word like "hotel near placename" and check the
response result

Google MAP Api http Request

I am making an iphone app that enables users to search for a city/town/countries/states by keying in texts in a UISearchbar, I managed to get the reply from google via JSON. It works ok, but I have some unexpected replies for certain places.
When I search for, say, "Vietnam", "China", "Malaysia", "Indonesia" it gives 0 results.
But when I search for, "Singapore", "Cambodia", then, it gives a result fine.
I don't get it, why does some countries aren't available as the search results?
Thanks.
Codes: The http request I sent is something like:
http://maps.google.com/maps/geo?q=%#?output=json
The %# is a searchBar.text formatter.
So if i type Indonesia, basically the request becomes:
http://maps.google.com/maps/geo?q=Indonesia?output=json
Instead of using an undocumented output of maps.google.com, you should try using the Geocoding API:http://code.google.com/apis/maps/documentation/geocoding/#JSON Your query would be something like:
http://maps.googleapis.com/maps/api/geocode/json?address=indonesia&sensor=false

finding both "Shopping_mall" and "food" within single URL for google places API

I tried following URLs to get both "shopping_mall" and "food" within a single request.
https://maps.googleapis.com/maps/api/place/search/json?location=%#,%#&radius=1500&sensor=true&key=%#&types=shopping_mall|food
This gives me response with only "food" type of places.
But,
https://maps.googleapis.com/maps/api/place/search/json?location=%#,%#&radius=1500&sensor=true&key=%#&types=shopping_mall
Gives the result with "shopping_mall" only. Also, The same URL with "food" only give the result same as "shopping_mall|food".
Has anyone faced this issue. I have searched across but cannot find any useful answer to that.
P.S. I have gone through this link and this link , too.
If you are getting only food in the first request, and you're getting 20 results, then it is likely Google believes the most relevant results are food. You may have to do 2 requests. You can try adding keyword=shopping, but that may limit your food results.

What do the keys in Facebook's 'data-ft' JSON structure represent?

On Facebook pages, many HTML elements include a 'data-ft' JSON object that is of the form:
data-ft='{
"src":10,
"sty":263,
"actrs":"117307284966434",
"targets":"117307284966434",
"pub_time":1317143005,
"fbid":"153538678072594",
"qid":"5657092603540274768",
"s_obj":5,
"s_edge":1,
"s_prnt":28,
"ft_prefix":"feed_story.top_news",
"ft_story_name":"StreamStoryCreateGeneric_ShareStreamContent_External_Other",
"mf_story_key":"10150331666719785",
"object_id":"153538678072594",
"mf_objid":"153538678072594",
"viewstate_id":"3201743663063655712",
"sub_level":"mid",
"sbj_type":"page",
"is_boulder":"1",
"authentic":1,
"pageid":"117307284966434",
"filter":"h",
"pos":14
}'
What do these keys represent? Some of them are straightforward, such as 'sty' as style, 'actrs' is the Facebook-ID of the original poster, and 'pub_time' is the UNIX epoch representation of the post date & time.
In particular, I am interested in understanding what the 'authentic' key represents, as well as the 'fbid' and 'qid' values.
Thanks for your insight, SO.
This is the root of how BFB (Better Facebook user script) can allow filtering, tabbing, etc.
In the HTML source, there is an attribute on each post that looks like this:
data-ft:{
"src":10, "sty":46, "actrs":"14385334364",
"pub_time":1289830690, "fbid":"1485431831867", "s_obj":11, "s_edge":1,
"s_prnt":11, "pos":1, "sec":"new", "filter":"lf",
"app_id":"201278444497"
}
This is the data we need!
BFB parses this when processing each post and extracts the data.
sty = Story type. Each type of story, like wall posts, status updates, pictures, links, etc has a unique story type with its own number. Unfortunately, these are not documented anywhere! I have to figure out the types by observation and trial and error. It's painful. But knowing this type numbers allows BFB to do filtering based on what kind of story it is.
actrs = The unique Facebook id's of the person (or people) that made the post. Again, good for filtering.
pub_time = The time the post was made. This is useful later...
fbid = The unique Facebook ID of the post. Every post has its own ID. At least, it should. See the explanations below for why this is not as reliable as it sounds
app_id = The unique ID of the Facebook application that made this post