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() {
缺點,無法在一篇文章添加評論...
什麼可能呢?
謝謝你的時間。