Check if app is liked on Facebook without requesting permission
public boolean isLikedOnFacebook( String signedRequest ) throws IOException, JsonException
{
String payload = signedRequest.split( "\\." )[ 1 ];
String replaced1 = payload.replaceAll( "-", "+" );
String replaced2 = replaced1.replaceAll( "_", "/" );
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes = null;
decodedBytes = decoder.decodeBuffer( replaced2 );
String decodedString = new String( decodedBytes );
JsonObject jsonObject = new JsonObject( decodedString );
if( jsonObject.getJsonObject( "page" ).get( "liked" ).equals( "true" ) )
{
return true;
}
else
{
return false;
}
}
Comments
blog comments powered by Disqus