我已经使用Uri在墙上成功发布了图像,但现在我想从drawable / assets文件夹发布图像,这就是我正在做的事情。
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
PackageManager m = MainTabActivity.this.getPackageManager();
String s = MainTabActivity.this.getPackageName();
Uri path = Uri.parse("android.resource://"+s+"/"+R.drawable.app_icon);
Bundle postParams = new Bundle();
postParams.putString("message", message+"\n\"App testing (no comments/likes)\"");
postParams.putString("picture", path.getPath());
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
String postId = null;
try
{
JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(TAG,"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null)
Toast.makeText(getBaseContext(), error.getErrorMessage(),Toast.LENGTH_SHORT).show();
else
Toast.makeText(getBaseContext(), postId, Toast.LENGTH_LONG).show();
}
};
Request request = new Request(session, "me/feed", postParams, HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
//这就是我试图从drawable文件夹中获取图标的方法 Uri path = Uri.parse(“android.resource://”+ s +“/”+ R.drawable.app_icon);
回调获取此结果 {Response:responseCode:400,graphObject:null,error:{HttpStatus:400,errorCode:100,errorType:OAuthException,errorMessage:(#100)picture URL格式不正确} ,isFromCache:false}
我做错了什么?
提前致谢
答案 0 :(得分:2)
“图片”值必须是网址。它不能是二进制数据。