我已经检查了堆栈溢出和 facebook 开发站点上的所有相关帖子。我不知道是什么问题,为什么我无法通过 Android 在 Facebook 上发布照片。
这是代码。
public static void AuthFB()
{
facebook = new Facebook(YOUR_APP_ID);
facebook.authorize((Activity) myCxt, new DialogListener() {
@Override
public void onComplete(Bundle values) {
postImageonWall("/mnt/sdcard/cmtdd.png");
Log.d("FB","Yes Called");
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
现在验证完成后,我将图像发布到墙上。这是代码。
public static void postImageonWall(String FilePath) {
Bitmap bi = BitmapFactory.decodeFile("/mnt/sdcard/cmtdd.png");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] data = baos.toByteArray();
Bundle params = new Bundle();
params.putString("method", "photos.upload");
params.putByteArray("picture", data);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/photos", params, "POST", new RequestListener() {
public void onMalformedURLException(MalformedURLException e, Object state) {
Log.d("request RequestListener", "debug onMalformedURLException");
}
public void onIOException(IOException e, Object state) {
Log.d("request RequestListener", "debug onIOException");
}
public void onFileNotFoundException(FileNotFoundException e, Object state) {
Log.d("request RequestListener", "debug onFileNotFoundException");
}
public void onFacebookError(FacebookError e, Object state) {
Log.d("request RequestListener", "debug onFacebookError");
}
public void onComplete(String response, Object state) {
Log.d("request RequestListener", "debug onComplete");
}
}, null);
}
方法 onComplete 被调用。但是没有任何东西上传到我的墙上。谁能告诉我错误在哪里?