开发者

Facebook Graph API Search without logged in user

I'm trying to issue a Facebook Graphp API search call for groups with a specific search term. The important fact is to search for groups not only beginning with the term but also to search for the term within the group name. So something like that.

FQL => SELECT * FROM groups WHERE groupname LIKE '%term%'

As far as i know this isn't possible in FQL. Therefore I have to use the Graph API search.

http://devel开发者_运维技巧opers.facebook.com/docs/api#search

But I have to issue th call even if the user isn't logged in. Is this possible or is there a possibility to log in a default user with some curl calls without user interaction (without displaying a form)?

If there is a simplier solution (for instance with FQL) please tell me.


I work with the graph API and not with the FQL so I'm not 100% sure on the differences etc etc... however a way I'd try is using the cURL script at http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application to get an auth token, then you must add the received auth token to the graph parameters as you can see on the site (a good way to test in the graph api is to click on the example likes or queries given while logged into facebook then copying the api code and breaking up the process like that [testing that you can get results you want from the query, testing that you can get your auth token then combining] so that you know what parts are 'problem' parts).

If that fails, scroll down to the "single sign-on with java-script" and have a look at the code they use to get the auth token from the facebook cookie, I notced you may be able to access that cookie from FQL.

I hope this was of some help! Please tell me if those ideas didn't work.

Jon


Using PHP-SDK 3.1.1, no auth or access_token needed. This sample assumes you have PHP-SDK installed on the page.

  1. Use a form post the question to the page, arguments for get and post are included. This will return the array from search https://graph.facebook.com/search?q=facebook&type=group

<?php
    $q = urlencode($_GET['qs']);
        if(!$_GET['qs']){
        $q = urlencode($_POST['qs']);
            if(!$_POST['qs']){
        $q = "facebook";
        }
    }
    $MEsearch = $facebook->api('/search?q='.$q.'&type=group');
       foreach ($MEsearch as $key=>$value) {
       $i=1;
          foreach ($value as $fkey=>$fvalue) {
          $i++;
          if($fvalue[id]=="h"){
          }else{
            $groupname = $fvalue[name];
            $groupid = $fvalue[id];
            $groupversion = $fvalue[version];
               echo $groupname. '<br />';
               echo $groupid. '<br />';
               echo $groupversion. '<br /><hr />';
          }
       };
    };
?>

Sample Usage http://shawnsspace.com/plugins/photofeed.php Click Get Plugin at the bottom and use the search box to see this sample in action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜