ianlee-dev / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

Users.getInfo cannot currently be called without providing a session key #87

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Users.getInfo can be now be called without providing a session key to
obtain a subset of the information that is available when a session key is
provided.

Fields which can be obtained without a session key include first name, last
name, name, locale, affiliations (regional type only), profile picture and
profile URL.

http://wiki.developers.facebook.com/index.php/Users.getInfo

There is currently no way to call Users.getInfo using the Facebook Java API
client library without having the session key appended to the request.

I am using version 1.8.0.

To get around this until the issue is resolved, we have a patched version
with the following changes:

1. We added the following at line 63 of FacebookMethod.java
  USERS_GET_INFO_NOSESSION("facebook.users.getInfo", 2),

2. We added the following to listSessionOptional at line 224 of
FacebookMethod.java
  USERS_GET_INFO_NOSESSION 

3. We added the following two methods at line 1432 of FacebookRestClient.java

  public Document users_getInfo_noSession( Collection<Long> userIds,
Collection<ProfileField> fields ) throws FacebookException, IOException {
    assert ( userIds != null );
    assert ( fields != null );
    assert ( !fields.isEmpty() );
    return callMethod( FacebookMethod.USERS_GET_INFO_NOSESSION, new
Pair<String,CharSequence>( "uids", delimit( userIds ) ), new
Pair<String,CharSequence>( "fields",
        delimit( fields ) ) );
  }

  public Document users_getInfo_noSession( Collection<Long> userIds,
Set<CharSequence> fields ) throws FacebookException, IOException {
    assert ( userIds != null );
    assert ( fields != null );
    assert ( !fields.isEmpty() );
    return callMethod( FacebookMethod.USERS_GET_INFO_NOSESSION, new
Pair<String,CharSequence>( "uids", delimit( userIds ) ), new
Pair<String,CharSequence>( "fields",
        delimit( fields ) ) );
  }

Hopefully posting the above will help to have something similar added to
the next version of the library. This is only a suggestion and may not
necessarily be the correct thing to do.

Original issue reported on code.google.com by chikinl...@gmail.com on 15 Aug 2008 at 8:05

GoogleCodeExporter commented 8 years ago
The optional session facebook calls are documented here:
http://wiki.developers.facebook.com/index.php/Category:Session_Optional_API

I'm going to apply a similar workaround for friends_getAppUsers . Some of the
information that you can get at without a session is posted into your canvas 
page as
request parameters. You get the user's ID and their friends' IDs. I initially 
filed a
bug report to ask for a request parameter for the friends' IDs with the relevant
application installed: http://bugs.developers.facebook.com/show_bug.cgi?id=3327
However, I feel that the best option is actually to use this sessionless call 
to the
facebook API; there will be many applications that won't want this information 
posted
to their canvas page every time.

The HTTP request params are documented here:
http://wiki.developers.facebook.com/index.php/Authorizing_Applications
I'm building a simple object into my code that will fetch these parameters from 
the
request and add them to the session. I'll post the code when it's finished.

Overall, based on these new features from facebook we need to modify the API so 
that
it can:
   * Pick up request parameters for simple things like "get user ID". Don't bother
going across the network if not necessary.
   * Make it clear when we have a session available and when we do not. Have a Java
interface which developers can use to call only "sessionless" API calls and make
requesting a session into a big deal.

The new facebook features are a good step forward, allowing developers to make 
most
of their application's features available to casual users who don't want to
"authorize" the application. It would be great if a clear line could be drawn 
in the
API so that it's obvious when you're going to force the user to bother with
authorization (which will put 50% of your users off).

Original comment by david.j....@googlemail.com on 25 Sep 2008 at 7:58

GoogleCodeExporter commented 8 years ago
Copied from http://code.google.com/p/facebook-java-api/issues/detail?id=105 
which is
a similar issue requesting that the sessionless API be supported. Suggested that
issue 105 should be closed in favour of this issue.

Reported by dleshem, Sep 09, 2008

Facebook are updating their friends.get API call, to support retreiving 
the friends lists of users other than the logged-in user. This is 
especially useful when using a sessionless client.

See this thread for details:
http://bugs.developers.facebook.com/show_bug.cgi?id=3027

Original comment by david.j....@googlemail.com on 25 Sep 2008 at 8:03

GoogleCodeExporter commented 8 years ago
If the sessionless method calls are a strict subset of all the method calls 
(and it
stands to reason that they are) then it may make sense to have an
IFacebookSessionlessRestClient and then have:

interface IFacebookRestClient extends IFacebookSessionlessRestClient

In that way, developers could create a new FacebookRestClient or ExtendedClient
implementation and cast it down to IFacebookSessionlessRestClient. They could 
then be
sure that they are only able to call sessionless methods. If the developer ever
needed to make a session based API call, the developer could recast the client 
to
IFacebookRestClient. It would be clear in the code where the user will be asked 
to
authorize the application if they haven't already done so.

Original comment by david.j....@googlemail.com on 25 Sep 2008 at 8:13

GoogleCodeExporter commented 8 years ago
Any progress resolving this issue?

This is probably the library's single most important issue, as it practically 
prevents using the Java library in an offline application.

Original comment by dles...@gmail.com on 24 Oct 2008 at 12:18

GoogleCodeExporter commented 8 years ago
have you tried the latest 2.0.2 version?  It should be a lot closer to what you 
need.
 the 1.8.x versions are old and deprecated..

I will look into getting friends without a session key, i don't think I've seen 
that
used yet.

Original comment by fern...@gmail.com on 26 Oct 2008 at 11:45

GoogleCodeExporter commented 8 years ago
@fernman: I am using the latest 2.0.2 version. This version indeed supports the 
sessionless users_getInfo, but not the sessionless friends_get.

For further details, see issue 105 (http://code.google.com/p/facebook-java-
api/issues/detail?id=105) and the thread it mentions. In short, the Java 
library 
doesn't support the new "uid" parameter for friends_get, so this method can 
only be 
called for the currently logged-in user.

Original comment by dles...@gmail.com on 27 Oct 2008 at 12:43

GoogleCodeExporter commented 8 years ago
cool. i guess i fixed this yesterday then :) try out 2.0.3-SNAPSHOT if you can.

Original comment by fern...@gmail.com on 31 Oct 2008 at 2:29

GoogleCodeExporter commented 8 years ago
Many thanks - just downloaded the latest svn version, and everything works! :)

Original comment by dles...@gmail.com on 31 Oct 2008 at 2:53