2
我试图在我的墙上发布一张照片,使用的是面向Android的Facebook sdk 3.0。 下面的代码:在facebook上发布墙上的照片sdk
GraphObject graphObject = GraphObject.Factory.create();
Bitmap bmp = BitmapFactory.decodeFile(loadFinalImageSavedFullPath());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
graphObject.setProperty("source", Base64.encodeToString(byteArray, Base64.DEFAULT);
graphObject.setProperty("message", "sup");
com.facebook.Request.executePostRequestAsync(fSession, "me/photos", graphObject, new Callback() {...}
,但我总是收到此错误:
I/facebook(10707): {Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 324, errorType: OAuthException, errorMessage: (#324) Requires upload file}, isFromCache:false}
我试过没有Facebook的API要发布:
@Override
protected Boolean doInBackground(String... params) {
Bitmap bmp = BitmapFactory.decodeFile(loadFinalImageSavedFullPath());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
List<NameValuePair> pm = new ArrayList<NameValuePair>();
pm.add(new BasicNameValuePair("access_token", params[0]));
pm.add(new BasicNameValuePair("message","sup"));
pm.add(new BasicNameValuePair("source", Base64.encodeToString(byteArray, Base64.DEFAULT)));
String res = postJSONString(https://graph.facebook.com/me/photos, pm);
Log.i(TAG, res);
if (res == null || res.contains("error")) {
return false;
}
return true;
}
同样的问题...
I/facebook(2977): {"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}
看起来这是我管理它的工作的唯一办法:
com.facebook.Request.executeUploadPhotoRequestAsync(fSession, bmp, new Callback() {
缺点,无法在一篇文章添加评论...
什么可能呢?
谢谢你的时间。