1
我已經使用Uri在牆上成功發佈了圖片,但現在我想從drawable/assets文件夾發佈圖片,這就是我正在做的。從drawable/assets發佈在Facebook牆上的圖片android
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();
}
//這是我怎樣,我試圖從繪製的文件夾圖標獲得 URI路徑= Uri.parse( 「android.resource://」 + S + 「/」 + R.drawable.app_icon );
回調取該結果{響應:responseCode:400,graphObject:空,錯誤:{的HTTPStatus:400,錯誤碼:100,ERRORTYPE:OAuthException,的errorMessage:(#100)圖片URL的格式不正確} ,isFromCache:false}
我在做什麼錯?
在此先感謝
您的意思是我無法從牆上的可繪製文件夾中發佈圖片? – Khawar 2013-03-06 04:48:52
「me/feed」的帖子僅用於狀態更新/鏈接共享,「picture」參數必須是URL(請參閱https://developers.facebook.com/docs/reference/api/user/#posts )。如果您想從設備發佈圖片,則需要發佈到「我/照片」,並且您可能需要先將Drawable轉換爲位圖(請參閱https://developers.facebook.com/docs/reference/ API /用戶/#照片)。 – 2013-03-06 18:15:02