eddiefeng / facebook-java-api

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

incorrect signature while users_getInfo 2.0.4 #157

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

when upgrading java api I get

com.google.code.facebookapi.FacebookException: Incorrect signature
       at
com.google.code.facebookapi.FacebookJaxbRestClient.parseCallResult
(FacebookJaxbRestClient.java:362)
       at com.google.code.facebookapi.ExtensibleClient.callMethod
(ExtensibleClient.java:526)
       at com.google.code.facebookapi.ExtensibleClient.callMethod
(ExtensibleClient.java:448)
       at com.google.code.facebookapi.ExtensibleClient.users_getInfo
(ExtensibleClient.java:696)

I'm using  this method from 1.8 release and worked ok.
Have checked if parameter have changed or something but no.

Here's piece of code:
                       FacebookJaxbRestClient client = new
FacebookJaxbRestClient(m_apiKey, m_secret);
                       client.setIsDesktop(true);
....

                       long logged = client.users_getLoggedInUser();
                       Long u = new Long(logged);
                       List<Long> list_u = new LinkedList<Long>();
                       list_u.add(u);
                       client.users_getInfo(list_u, EnumSet.of(
                               ProfileField.NAME,
                               ProfileField.PIC_SMALL,
                               ProfileField.STATUS,
                               ProfileField.PIC_BIG
                               ));

exception is thrown at users_getInfo line.

client is loged in, I get proper user id back .

Kind regards, pixi

Original issue reported on code.google.com by david.j....@googlemail.com on 10 Jan 2009 at 11:21

GoogleCodeExporter commented 8 years ago
JUnit test checked in to prove that the feature works.

Original comment by david.j....@googlemail.com on 10 Jan 2009 at 11:29

GoogleCodeExporter commented 8 years ago
I have the same problem like David. Does anyone know where I have mistake?

There is piece of my code:

FacebookJsonRestClient client =
      new FacebookJsonRestClient(API_KEY, SECRET);
    client.setIsDesktop(true); 

    try {
       String token = client.auth_createToken();

       String url = "http://www.facebook.com/login.php?api_key="
                + API_KEY + "&v=1.0"
                + "&auth_token=" + token;

      Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
      System.in.read();

      String session = client.auth_getSession(token);
      System.out.println("Session key is " + session);

      client.friends_get();    // there I get exception
...

com.google.code.facebookapi.FacebookException: Incorrect signature
        at
com.google.code.facebookapi.FacebookJsonRestClient.parseCallResult(FacebookJsonR
estClient.java:351)
        at
com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:53
1)
        at
com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:45
3)
        at
com.google.code.facebookapi.ExtensibleClient.friends_get(ExtensibleClient.java:8
17)
        at
com.google.code.facebookapi.FacebookJsonRestClient.friends_get(FacebookJsonRestC
lient.java:639)
        at deff.FacebookClient.main(FacebookClient.java:61)

Original comment by mirda.ho...@gmail.com on 16 Mar 2009 at 11:00

GoogleCodeExporter commented 8 years ago
The unit test uses the XML client. I'm using the JSON client like Comment 2 and 
I
also get the same error as these guys.

Possibly add a unit test with the JSON and Jaxb clients to see if there might 
be a
problem?

Original comment by boardmanjohnw@gmail.com on 26 Mar 2009 at 5:38

GoogleCodeExporter commented 8 years ago
To make it work, I added this to use the session secret generated by Facebook
whenever you set IsDesktop to true:

...
String session = client.auth_getSession(token);
String fbSessionKey = client.getSessionSecret();
FacebookJsonRestClient client = new FacebookJsonRestClient(apiKey, fbSessionKey,
fbSessionId);
client.setIsDesktop(true);

Now the session secret is used instead of your app secret. Since apparently 
Facebook
is doing this as well, the signatures started matching, and I finally got
client.feed_publishUserAction() to work.

Incidentally, when I set IsDesktop to false I could never get
client.auth_getSession(token) to work. I always got "Invalid Parameter"

Hope this helps!
John

Original comment by boardmanjohnw@gmail.com on 26 Mar 2009 at 7:58

GoogleCodeExporter commented 8 years ago
I've added a comment to:
http://code.google.com/p/facebook-java-api/wiki/DesktopMode

What you set your application's mode to really matters. I think it explains all 
the
JUnit test Invalid Signature problems we're seeing.

Original comment by david.j....@googlemail.com on 26 Mar 2009 at 10:10

GoogleCodeExporter commented 8 years ago
A question for the boardmanjohnw's comment 4:
How can you use the client.* in 1 and 2 before you declare it in line 3?

1 String session = client.auth_getSession(token);
2 String fbSessionKey = client.getSessionSecret();
3 FacebookJsonRestClient client = new FacebookJsonRestClient(apiKey, 
fbSessionKey,
fbSessionId);

Original comment by gamberi....@gmail.com on 11 Nov 2009 at 9:42

GoogleCodeExporter commented 8 years ago
Sorry I messed up when I posted comment 4. It turns out that this still did not 
allow
obtaining a session every time. In fact I received the "Invalid Parameter" 
exception
about 8 out of every 10 tries or so. I ended up rewriting it to use Facebook 
Connect
and now it works every time.

Original comment by boardmanjohnw@gmail.com on 12 Nov 2009 at 4:13

GoogleCodeExporter commented 8 years ago
Me too, but know I have another problem, when I make the getInfo API call with 
this code:
FacebookJsonRestClient client = new FacebookJsonRestClient( APIKey, SecretKey)
            client.setIsDesktop(true)
        String infos = client.users_getInfo(uid,'last_name')
            println infos

it gives me this exception:
No signature of method:
com.google.code.facebookapi.FacebookJsonRestClient.users_getInfo() is 
applicable for
argument types: (java.lang.Long, java.lang.String) values: [6xxxxxxxx, 
last_name]

I haven't understand if the problem are the type of the uid and field or 
something
else..Can you help me?

Original comment by gamberi....@gmail.com on 12 Nov 2009 at 5:44

GoogleCodeExporter commented 8 years ago
Solved...
String infos = client.users_getInfo([uid],['last_name'])
I have to pass it an array also if it contain only one element!!

Original comment by gamberi....@gmail.com on 12 Nov 2009 at 6:53

GoogleCodeExporter commented 8 years ago
i found valueble info for this issue using information from
http://code.google.com/p/facebook-java-api/wiki/DesktopMode

pay attention to retrieving the TEMP SECRET for desktop applications

String tempSecret = client.getCacheSessionSecret();

Original comment by judit.fo...@gmail.com on 3 Feb 2010 at 9:20