Closed GoogleCodeExporter closed 8 years ago
I have the same problem, also with 3.0.1-SNAPSHOT but using Linux.
I don't seem to get the problem when checking the STATUS_UPDATE permission,
only when
checking the PUBLISH_STREAM permission.
See this thread for details:
http://groups.google.com/group/facebook-java/browse_thread/thread/1638b329af3353
07
Original comment by zyy...@gmail.com
on 14 Sep 2009 at 7:08
Here is a quick fix for the function extractBoolean in the file
ExtensibleClient.java:
protected boolean extractBoolean( String result ) throws FacebookException {
if ( "json".equals( responseFormat ) ) {
- return (Boolean) FacebookJsonRestClientBase.parseCallResult( result );
+ return (Integer) FacebookJsonRestClientBase.parseCallResult( result )
+ == 1 ? true : false;
} else {
FacebookXmlRestClient xmlClient = new FacebookXmlRestClient( this );
return extractBoolean( xmlClient.parseCallResult( result ) );
Works for me(tm)
Original comment by zyy...@gmail.com
on 15 Sep 2009 at 12:17
You don't need the "? true : false;"
It's silly returning something that evaluates to:
(if (x) return x else return !x)
you can simply return x...
But yeah, that's what I did too a while ago, and it works fine..
The problem is that I can't just add the maven source and have the entire
company
simply use maven to update.
I had to add the jar manually to our repository, give it a fake version number
to
make the deployment simple...
Original comment by enricoma...@gmail.com
on 15 Sep 2009 at 12:29
[deleted comment]
[deleted comment]
D'oh!
return ((Integer) FacebookJsonRestClientBase.parseCallResult( result )) == 1;
it is
Original comment by zyy...@gmail.com
on 15 Sep 2009 at 12:38
[deleted comment]
The previously proposed solutions are only a temporary fix for this specific
case.
Making this change causes issues in other areas of the API such as
ExtensibleClient.auth_revokeAuthorization(). This change now causes that method
to
toss a ClassCastException:
11:39:52,188 ERROR [STDERR] TYPE: class java.lang.ClassCastException
11:39:52,188 ERROR [STDERR] FROM:
com.google.code.facebookapi.ExtensibleClient.extractBoolean(ExtensibleClient.jav
a:2810)
11:39:52,188 ERROR [STDERR] FROM:
com.google.code.facebookapi.ExtensibleClient.auth_revokeAuthorization(Extensible
Client.java:2027)
11:39:52,188 ERROR [STDERR] FROM:
com.google.code.facebookapi.SpecificReturnTypeAdapter.auth_revokeAuthorization(S
pecificReturnTypeAdapter.java:122)
...
11:39:52,189 ERROR [STDERR] MSG: java.lang.Boolean cannot be cast to
java.lang.Integer
I working fix for both problems really should be addressed in the
ExtensibleClient.users_hasAppPermission(Permission perm, Long userId) method.
The
Facebook API states that this call returns 1 (true) or 0 (false), therefore this
method should use the extractInt() method instead of extractBoolean().
public boolean users_hasAppPermission( Permission perm, Long userId ) throws
FacebookException {
if ( userId != null ) {
+ int result = extractInt( callMethod(
FacebookMethod.USERS_HAS_APP_PERMISSION_NOSESSION, newPair( "ext_perm",
perm.getName() ), newPair( "uid", userId ) ) );
+ return (result == 1);
- return extractBoolean( callMethod(
FacebookMethod.USERS_HAS_APP_PERMISSION_NOSESSION, newPair( "ext_perm",
perm.getName() ), newPair( "uid", userId ) ) );
} else {
+ int result = extractInt( callMethod(
FacebookMethod.USERS_HAS_APP_PERMISSION,
newPair( "ext_perm", perm.getName() ) ) );
+ return (result == 1);
- return extractBoolean( callMethod(
FacebookMethod.USERS_HAS_APP_PERMISSION,
newPair( "ext_perm", perm.getName() ) ) );
}
}
Let me know if anyone has issues with this fix.
Original comment by mcdonald...@gmail.com
on 13 Oct 2009 at 10:49
fixed
Original comment by fern...@gmail.com
on 31 Oct 2009 at 12:33
Original issue reported on code.google.com by
enricoma...@gmail.com
on 7 Sep 2009 at 6:40