How to use keywords include ampersand(&) in Facebook Search API - facebook

I want to use some keywords that include special characters like & in Facebook search api. I tried the query below but I cannot get useful results. Is there any chance for this usage in search api? How should I build my search query?
My example queries and keywords are "H&M", "marks & spencer",
http://graph.facebook.com/search?type=post&limit=25&q="H&M"
http://graph.facebook.com/search?type=post&limit=25&q="marks & spencer"

My team worked on this forever, ended up finding this as a solution that provides relevant results for a query with an ampersand, such as 'H&M'.
%26amp%3b
This is the hex equivilent to &
So your example link would be
http://graph.facebook.com/search?type=post&limit=25&q="H%26amp%3bM"
We found the solution thanks to Creative Jar

You want %26 which is the URL encode for ampersand so
http://graph.facebook.com/search?type=post&limit=25&q="H%26M" http://graph.facebook.com/search?type=post&limit=25&q="marks %26 spencer"
Depending on your language, it may have a URL encoding function or you can just use string replacement.

It seems, that all of solutions suggested here are not working any more.
Searching for q=H%26%bM returns empty data set. The same for q=H%26M.
It must have changed recently, in last 2 months.
If you try to search for postings about H&M on Facebook site (type H&M in search, then "Show me more results" on the bottom of list and then public posts on menu on the left side) the list is empty.
The only query that returns any results is q=H&M but it is not helpful, as the results are irrelevant for that query.

Related

RegEx for google event

Hello I would like help writing a regex that captures all urls with the word confirmation in it.
Ex:
https://example.com/this-is-a-confirmation
https://example.com/confirmation
https://example.com/folder/this-is-confirmation
I am trying to set up a Goal that captures all visits to any confirmation page on the website as by visiting that page you most likely filled out a form to download an asset
Thanks!
So, basically all links end with confirmation?
Then you could just use a very stupid and simple regex like:
confirmation$
If you only want the URL to contain confirmation:
confirmation
is already enough (Demo). That's basically the same as if you were using String.endsWith(str) and String.contains(str).
Depending on the way you're evaluating this, you may need to allow chars before the search term to produce a full match (not only a partial match):
.*confirmation
or
.*confirmation.*
if you want to allow any text after the search term.

How to allow leading wild cards in custom smart search web part (Kentico 10)

I have a custom index for my products and I am using the Subset Analyzer. This Analyzer works great, but if you do field searches, it does not work.
For example, I have a document with the following fields:
"documentname", "My-Document-Name"
"tags", "1234,5678,9101"
"documentdescription", "This is a great Document, My-Document-Name."
When I just search "name AND tags:(1234)", I get this document in my results because it searches +_content:name.
-- However:
When I search "documentname:(name)^3.0 AND tags:(1234)", I do not get this document in my results.
Of course, when I do "documentname:(*name*)^3.0" I get a parse error saying: '*' or '?' not allowed as first character in WildcardQuery.
How can I either enable wildcard query in my custom CMS.Search webpart?
First of all you have to make sure that a field you checking is in the index with proper name. documentname might not be in the index it can be called _title, depends how you index is set up. Get lukeall and check your index (it should be in \CMS\App_Data\CMSModules\SmartSearch\YourIndexName). You can use luke to test your searches as well.
For examples there is no tags but there is documenttags field.
P.S. Wildcards are working and you are right you can't use them as a first character by default (lucene documentation says: You cannot use a * or ? symbol as the first character of a search), but there is a way to set it up in lucene.net, although i dont know if there are setting for that in Kentico. But i dont think you need wildcards, so your query should be (assuming you have documentname and documenttags in the index):
+(documentname:"My-Name" AND documenttags:"tag1")

Use Google Places autocomplete vs nearbysearch with rankby=distannce

I am looking to use Google Places autocomplete to help user search for places near him/her. When using autocomplete in the example below, I get establishment that are very far from the location.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=pizza&types=establishment&location=37.340871,%20-122.029642&rankby=distance&key=mykey
I assume Google considers the popularity of the establishment in the result set. My question: is there a way to get back the list sorted by proximity to the location, i.e. "turn off" the popularity index? (and to get similar functionality to the nearbysearch with autocomplete) ?
Why not just using nearbysearch? because nearbysearch does not perform well when only part of the name is entered as keyword ( I assume nearbysearch assume the 'keyword' parameter is the complete word).
Thanks for your help!

How to get larger version of Facebook's thumbnail images?

Right now the Facebook API is returning a URL like this with all post/album images 130x130 pixels in size:
https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/s130x130/10801504_570625556403546_6496651209845129904_n.jpg?oh=dcf8ab3752522532871d2aaab09b6e7e&oe=54E4402F&gda=1424027679_76464aeeaa5d232b8100d01476af4ec7
How do I retrieve a full (or any bigger size) image based on that URL?
For example this one:
https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/p417x417/10801504_570625556403546_6496651209845129904_n.jpg?oh=cd2b5cb0d74f7306c098de9f56dc6e27&oe=54E1F4C1&gda=1423830001_e700bfac39039952bfee55b200c158bf
or anything like that?
All the other suggestions of removing s130x130 from the URL, or /v/t1.0-9/, or replacing _s with _n or anything like that aren't valid any more - I've tried them all (try them yourself if you don't believe me). Is there a way to make this happen? Not sure what Facebook guys have changed to disable that...
After a couple of hours searching and pulling my hair out, I found a solution that works for me. In my case I'm pulling posts from {page-id}/posts, but I'm pretty sure this will work for you too, seeing that I used to get larger images using the same approach as you mention.
This is works for me:
bigger_image="https://graph.facebook.com/" + picture_url_from_facebook.match(/_\d+/)[0].slice(1) + "/picture?type=normal";
/_\d+/ matches any substring starting with an underscore (_) followed by any digits (\d matches one digit, \d+ does the digit match over and over until it fails)
match(regex) returns an array with all strings it could find matching the specified regex
we grab the first ([0]) element, as this will be an underscore followed by the ID of the picture in Facebook's database
we slice the string from index 1 to the end, as the underscore is not a part of the ID
we then get a working link from facebook using the graph api without the need for any extra calls (you can use this in for example an img tag directly)
You can see this working in action # this fiddle or this page we did for a client
Thanks to Er Adhish for leading the way to the solution # https://stackoverflow.com/a/27075503/2908761
https://graph.facebook.com/{object_id}/picture?type={thumbnail|album|normal}
Example (using a bogus object_id of 122233334444555):
https://graph.facebook.com/122233334444555/picture?picture?type=large
Make sure object_id is not just the id of an item but it's object_id (which is typically the number following the underscore in the full id).
I got those type values from a helpful facebook response message that said:
"message": "(#100) type must be one of the following values: thumbnail, album, normal"
In place of ?type=... you could do height/width as well:
?width=543&height=543

Keyword search in facebook graph api

I am searching the facebook status which contains the specific keywords as follows.
https://graph.facebook.com/search?q=test&date_format=U&limit=60
&access_token={MY_ACCESS_TOKEN}
the above query returns the result correctly,
But when i search the keyword contains the space (ex: graph api). It doesn't returns the status which contains the keyword "graph api".
It returns the results of the keyword search graph and api seperately.
Is there any possible way to search the keywords which contains the space?
Update:
Methods which have been tried by me:
https://graph.facebook.com/search?q=facebook+search&date_format=U&
limit=60&access_token={{MY_ACCESS_TOKEN}}
https://graph.facebook.com/search?q=facebook%20search&date_format=U&
limit=60&access_token={{MY_ACCESS_TOKEN}}
https://graph.facebook.com/search?q=facebook%20Bsearch&date_format=U&
limit=60&access_token={{MY_ACCESS_TOKEN}}
https://graph.facebook.com/search?q="facebook search"&date_format=U&
limit=60& access_token={{MY_ACCESS_TOKEN}}
the above all gave the same result.
What you might want to try is taking your query and performing a URL encode on it. You can try these two options -
https://graph.facebook.com/search?q=graph+api&date_format=U&limit=60
&access_token={MY_ACCESS_TOKEN}
https://graph.facebook.com/search?q=graph%20api&date_format=U&limit=60
&access_token={MY_ACCESS_TOKEN}
These two options attempt to encode the space character in the query first with a + character, and then with %20. I'm fairly sure that one (or both) of these options will provide the results you are looking for.