{"错误":{"信息":"(#324)需要上传文件","类型":" OAuthException"," code":324}} [英] {"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}
问题描述
私人无效postToWall(弦乐味精){
捆绑参数=新包();
// parameters.putString(法,stream.publish);
JSONObject的附件=新的JSONObject();
尝试 {
byte []的数据= NULL;
位图BI = BitmapFactory.de codeResource(getResources()
R.drawable.bluerib);
//位图BI =
// BitmapFactory.de codeFILE(http://demos.com/LangGuage/medal_1.png);
ByteArrayOutputStream BAOS =新ByteArrayOutputStream();
bi.com preSS(Bitmap.Com pressFormat.JPEG,30,BAOS);
数据= baos.toByteArray();
//捆绑PARAMS =新包();
// params.putByteArray(图片报的数据);
attachment.put(类,图像);
// attachment.put(图片报的数据);
attachment.put(姓名,LangGuage);
attachment.put(信息,味精);
attachment.put(src用户,http://demos.com/LangGuage/medal_1.png);
attachment.put(的href,http://www.abc.com);
// attachment.put(HREF
//http://hwsdemos.com/LangGuage/medal_1.png);
parameters.putString(Facebook.TOKEN,facebook.getAccessToken());
parameters.putString(附件,attachment.toString());
字符串响应= facebook.request(ME /照片,参数,POST);
的System.out.println(----的反响+响应);
如果(response.contains(复制状态消息)){
progressHandler.sendEmptyMessage(1);
RESP = 1;
}否则,如果(响应== NULL || response.equals()
|| response.equals(假)|| response.contains(错误)){
Log.d(错误,错误反应);
} 其他 {
progressHandler.sendEmptyMessage(0);
RESP = 0;
}
}赶上(例外五){
Log.e(TAG,发帖失败);
e.printStackTrace();
// 完();
}
}
我的应用程序对于Facebook支持单一登录。我不想使用对话框。 每当我试图张贴图片和消息一起在附件我赶上:
{错误:{消息:(#324)需要上传文件,类型:OAuthException,code:324}}
请参阅该文档为这里的照片图POST请求的 https://developers.facebook.com/docs/reference/api/user/#photos
您的图像数据应该进入源字段,唯一的其他可用字段为消息,地点和no_story,源,姓名,HREF是无效的领域
private void postToWall(String msg) {
Bundle parameters = new Bundle();
// parameters.putString("method", "stream.publish");
JSONObject attachment = new JSONObject();
try {
byte[] data = null;
Bitmap bi = BitmapFactory.decodeResource(getResources(),
R.drawable.bluerib);
// Bitmap bi =
// BitmapFactory.decodeFile("http://demos.com/LangGuage/medal_1.png");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 30, baos);
data = baos.toByteArray();
// Bundle params = new Bundle();
// params.putByteArray("picture", data);
attachment.put("type", "image");
// attachment.put("picture", data);
attachment.put("name", "LangGuage");
attachment.put("message", msg);
attachment.put("src", "http://demos.com/LangGuage/medal_1.png");
attachment.put("href", "http://www.abc.com");
// attachment.put("href",
// "http://hwsdemos.com/LangGuage/medal_1.png");
parameters.putString(Facebook.TOKEN, facebook.getAccessToken());
parameters.putString("attachment", attachment.toString());
String response = facebook.request("me/photos", parameters, "POST");
System.out.println("----responce" + response);
if (response.contains("Duplicate status message")) {
progressHandler.sendEmptyMessage(1);
resp = 1;
} else if (response == null || response.equals("")
|| response.equals("false") || response.contains("error")) {
Log.d("error", "error response");
} else {
progressHandler.sendEmptyMessage(0);
resp = 0;
}
} catch (Exception e) {
Log.e(TAG, "Posting fail");
e.printStackTrace();
// finish();
}
}
My app is supporting single sign-in for facebook. I don't want to use dialogs. Whenever I try to post an image and message together in a attachment I catch:
{"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}
See the docs for a photos graph POST request here https://developers.facebook.com/docs/reference/api/user/#photos
Your image data should go into the "source" field, and the only other available fields are "message", "place' and "no_story". The "src", "name", "href" are not valid fields.
这篇关于{"错误":{"信息":"(#324)需要上传文件","类型":" OAuthException"," code":324}}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!