在Android上使用facebook sdk 3.0发布时的EOFException

时间:2013-10-14 06:19:02

标签: android facebook facebook-graph-api eofexception

我在Facebook上发帖,但我遇到了两个例外:

  • 无法构造正文异常
  • EOFException类

我尝试了很多解决方案但没有成功。

包括:

System.setProperty("http.keepAlive", "false");

thanx:)

哦,这次运行在服务上运行。

Session session = Session.getActiveSession();
    if(session==null) session = Session.openActiveSessionFromCache(getApplication());


    if (session != null){
        Log.d("Post Service", "session not null");
        // Check for publish permissions    
        List<String> permissions = session.getPermissions();
        if (!isSubsetOf(PERMISSIONS, permissions)) {
            pendingPublishReauthorization = true;
            Log.d("Post Service", "No Permissions to Post!");
            return;
        }

        Bundle postParams = new Bundle();
        postParams.putString("name", "AutoPost");
        postParams.putString("message", this.post);
        if(!this.piclink.equals(""))postParams.putString("picture", 
                this.piclink);


        for(int i=0;  i<this.groupsIds.length;i++){

            Log.d("Post Service", "posting to: "+this.groupsIds[i]);
        Request request = new Request(session, this.groupsIds[i]+"/feed", postParams, 
                              HttpMethod.POST);

        if(this.appStatus.isOnline(this.getApplicationContext())){
            Response resp = request.executeAndWait();
            if(resp.getError()!=null){
                Log.d("Post Service", "POST ERROR: "+resp.getError().toString());
                Log.d("Post Service", "POST EXECEPTION: "+resp.getError().getException().toString());
                this.notifMyUser("Post failed!post error",resp.getError().toString());
                this.notifMyUser("Post failed!post exeception",resp.getError().getException().toString());
                this.write("ErrorLog", this.groupsIds[i]+ ": "+resp.getError().toString());
                this.write("ErrorLog", this.groupsIds[i]+ ": "+resp.getError().getException().toString());  

            }
            else{
                JSONObject graphResponse = resp
                                       .getGraphObject()
                                       .getInnerJSONObject();
                String postName = null;
                try {
                    postName = graphResponse.getString("id");
                    Log.d("Post Service", "post successful to: "+postName.toString());
                    this.write("ErrorLog", "post successfuly to: "+postName.toString());
                    this.notifMyUser("Post-Success!","post successful to: "+postName.toString());
                } catch (JSONException e) {
                    Log.i("Post Service: ",
                            "trying to post, JSON error "+ e.getMessage());
                }
            }
        }
        else {
            this.notifMyUser("Post-NoConnection", "faild to post to "+ this.groupsIds[i]);
            this.write("ErrorLog", "faild to post to "+ this.groupsIds[i]);
        }

       }

     }
   }

1 个答案:

答案 0 :(得分:0)

让我试一下我使用这个repo :)只检查我以前的项目,在这种情况下,你可能会错过正确添加依赖项,如果你添加依赖项然后重建和清理你的项目,然后检查导入的R文件完全。