Facebook error : application ID is invalid

吃可爱长大的小学妹 提交于 2020-01-07 04:06:09

问题


Hey i get this error using the SDK though the app ID is correct.

Now when i try to authorize the app, it works fine and authorizes it, but when i try and make requests, facebook returns this error. My app is initlized properly and is not in sandbox mode.

I found No info about this problem, does someone know what can cause this?

I'm trying to upload photo using The following code :

    byte[] data = null; 

Bitmap bi = BitmapFactory.decodeFile(photoToPost); 
ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos); 
data = baos.toByteArray(); 

Bundle params = new Bundle(); 
params.putString("method", "photos.upload"); 
params.putByteArray("picture", data); 

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook); 
mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null); 

SampleUploadListener :

    public class SampleUploadListener extends BaseRequestListener { 

    public void onComplete(final String response, final Object state) { 
        try { 
            // process the response here: (executed in background thread) 
            Log.d("Facebook-Example", "Response: " + response.toString()); 
            JSONObject json = Util.parseJson(response); 
            final String src = json.getString("src"); 

            // then post the processed result back to the UI thread 
            // if we do not do this, an runtime exception will be generated 
            // e.g. "CalledFromWrongThreadException: Only the original 
            // thread that created a view hierarchy can touch its views." 

        } catch (JSONException e) { 
            Log.w("Facebook-Example", "JSON Error in response"); 
        } catch (FacebookError e) { 
            Log.w("Facebook-Example", "Facebook Error: " + e.getMessage()); 
        } 
    } 

    @Override 
    public void onFacebookError(FacebookError e, Object state) { 
        // TODO Auto-generated method stub 

    } 
} 

回答1:


I Solved the problem.

THe problem was i created 2 instances of the Facebook object, one as global and one inside the method preforming the code mentioned above, So what happened is i never authorized the Object i tried doing the request is.

For some reason the error dosen't say that but in case this happens to you, make sure you have initialised the right Object and it has a valid session



来源:https://stackoverflow.com/questions/10975266/facebook-error-application-id-is-invalid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!