{"error":{"message":"(#324) Erfordert upload file","type":"OAuthException","code":324}}
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();
}
}
Meine app ist die Unterstützung von single sign-in für facebook. Ich will nicht von Dialogen.
Immer wenn ich versuche zu posten ein Bild und Botschaft zusammen in eine Anlage, die ich fangen:
{"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}
- entfernen Sie diese
attachment.put("type", "image");
- Ich checkte nach dem entfernen dieser Zeile.aber immer noch die gleichen Fehler.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Siehe die Dokumentation für Fotos graph-POST-Anfrage hier https://developers.facebook.com/docs/reference/api/user/#photos
Ihre Bild-Daten sollten in der "Quelle" - Feld, und die einzige andere verfügbare Felder "Nachricht", "Platz" und "no_story". Die "src", "name", "href" sind nicht gültig Felder.