Facebook graph api multiple keyword search - facebook

I am using facebook graph api to search the keywords, like as follows
https://graph.facebook.com/search?q='test'&limit=60&access_token=(myAccessToken)
Which works fine and returns the data correctly.
But I want to search with multiple keywords (Eg . I need the post which contains the words 'test' or 'date')
I tried in the following way, which is working but returns the array which contains the words test and date. It doesn't return the results of individual words.
https://graph.facebook.com/search?q=test|date&limit=60&access_token=
(myAccessToken)
Is it possible to implement graph api search with multiple keywords in "OR" condition?
If so explain how?

I know that is one year later but did you manage to find a solution? I've tried with different methods, like putting " | " character, but nothing works. I'm wondering to give it a try to batch request, passing on each query each keyword that I'm interested in and loop later through the responses to filter repeated results.

You can use FQL. For example if you have two different artists pages and you want to get information about both:
$fql = 'SELECT name,fan_count,page_id,hometown,record_label from page WHERE name="Rihanna" OR name="Jay z" LIMIT 2';
$ret_obj = $facebook->api(array('method' => 'fql.query','query' => $fql));
foreach( $ret_obj as $var)
{
var_dump($var);
}
This code will return you an array that has the required information about both artists.

Related

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.

Facebook Open Graph Friend Array results are limited

I'm retrieving an array of my users' friends' ids using open graph api.
$friends = $facebook->api('/me/friends?limit=2000');
$friendsList = array();
foreach ($friends as $key=>$value)
{
foreach ($value as $fkey=>$fvalue) {
$friendsList[] = $fvalue[id];
}
}
The problem I have is that no matter what I put in the limit, I only receive a max of 500 friend id values for users that have more than 500 friends. I have been reading up on limits and pagination in Facebook Developers information with no luck.
Any ideas on what I need to do to retrieve all user's friend ID's? Why does the last value in the array show as "h"? All other values are id's.
THANKS!!!
Why does the last value in the array show as "h"?
Because you are doing a loop in a loop.
In the outer loop, you iterate over the two properties of the actual API response – data and paging.
And then, in the inner loop, you go through each of the arrays these properties point to. That’s a lot of results in the form of name and id; and then the second time the inner loop goes through the array that the paging property points to, and that has only one property that has the name/key next and the value https://graph.facebook.com/…
Now, since you are trying index-based access on the first value with $fvalue[id], since $fvalue contains actually the text literal https://graph.facebook.com/…, and there is no contant named id declared, PHP first interprets that as if "id" was ment, and then converts this string value to integer 0 for index-based access on $fvalue. And that gets you – since PHP also allows access to bytes (not characters) in a string variable index-based – the first byte, whose ASCII representation is the character h …
So, what you want to do is loop actually just once, but directly over the contents of $friends['data'].
If you just need facebook id then you should try with just id field, it should return all the friends id. with this I remember my app has handled a user with 1500 friends.
$friends = $facebook->api('/me/friends?fields=id');

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

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.

wordpress 3.2.1 database query

i am trying to make a simple selection in a wordpress table (created by a plugin). the table is named reduceri , and has the following columns: id, post, category.
so, i am trying to take all the category values, when the post is equal to the current post id.
the way i am doing the query is:
$the_query = "
SELECT $wpdb->reduceri.category
FROM $wpdb->reduceri
WHERE $wpdb->reduceri.post = ".$post_id."
";
$my_reduceri = $wpdb->get_results($the_query);
but when i var_dump the $my_reduceri all i get is an empty array: array(0) { } even though there should actually be some results... any idea where i am wrong (in the query)?
thank you
Did you declared global $wpdb; before using this query?

Zend GData Spreadsheet WorksheetID

What is the $worksheetId from the Zend GData documentation supposed to be?
http://framework.zend.com/manual/en/zend.gdata.spreadsheets.html
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$query->setWorksheetId($worksheetId);
$query->setSpreadsheetQuery('name=John and age>25');
$listFeed = $spreadsheetService->getListFeed($query);
The documentation uses that $worksheetId several times, but I can't seem to see where to get that from a spreadsheet.
If you don't know the worksheet identifiers, you have to perform a first query to retrieve the worksheets metafeed for your spreadsheet:
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$feed = $spreadsheetService->getWorksheetFeed($query);
Then, you iterate $feed->entries and each entry will represent a worksheet and have an identifier.
The $worksheetId is the worksheet identifier.
Worksheets have a gid identifier (1,2,....) that you can see directly in the url of the document when is opened.
Unfortunately you can't access to them through API with that id.
Use instead the codes that you find in the following discussion:
Worksheet GIDs