Facebook のグループに投稿していますが、2 つの例外に遭遇しました。
- ボディ例外を構築できませんでした
- EOF例外
私は多くの解決策を試しましたが、成功しませんでした。
これを含む:
System.setProperty("http.keepAlive", "false");
ありがとう:)
ああ、この実行はサービスで実行されます。
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]);
}
}
}
}