Facebook的错误:应用程序ID无效 [英] Facebook error : application ID is invalid

查看:264
本文介绍了Facebook的错误:应用程序ID无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我得到使用SDK虽然应用程序ID是正确的这个错误。

现在,当我尝试授权的应用程序,它工作正常,并授予它,但是当我尝试做的请求,Facebook的返回此错误。我的应用程序正确initlized,是不是在沙盒模式。

我发现关于此问题的信息,没有人知道是什么原因?

我想用下面的code上传照片:

 字节[]数据= NULL;位图双= BitmapFactory.de codeFILE(photoToPost);
ByteArrayOutputStream BAOS =新ByteArrayOutputStream();
bi.com preSS(Bitmap.Com pressFormat.JPEG,100,BAOS);
数据= baos.toByteArray();捆绑PARAMS =新包();
params.putString(法,photos.upload);
params.putByteArray(图片,数据);AsyncFacebookRunner mAsyncRunner =新AsyncFacebookRunner(脸谱);
mAsyncRunner.request(NULL,则params,POST,新SampleUploadListener(),NULL);

SampleUploadListener:

 公共类SampleUploadListener扩展BaseRequestListener {    公共无效的onComplete(最后字符串的响应,最终对象的状态){
        尝试{
            //此处流程的响应:(在后台线程执行)
            Log.d(脸谱-示例,回应:+ response.toString());
            JSONObject的JSON = Util.parseJson(响应);
            最终的字符串src = json.getString(SRC);            //然后发布处理结果返回给UI线程
            //如果我们不这样做,将会产生一个运行时异常
            //例如CalledFromWrongThreadException:只有原始
            //线程创建视图层次可以触摸的意见。        }赶上(JSONException E){
            Log.w(脸谱-示例,JSON错误反​​应);
        }赶上(FacebookError E){
            Log.w(脸谱-实施例,实错误:+ e.getMessage());
        }
    }    @覆盖
    公共无效onFacebookError(FacebookError即对象的状态){
        // TODO自动生成方法存根    }
}


解决方案

我解决了问题。

问题是我创建Facebook的对象的两个实例,一个作为全球和一个方法preforming上面提到的code里面,所以发生了什么事是我从来没有授权我尝试过的对象所做的请求

由于某些原因,错误这么想的说,但如果您遇到这种情况,请确保您已初始化合适的对象,它有一个有效的会话

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 

    } 
} 

解决方案

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

这篇关于Facebook的错误:应用程序ID无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆