Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

{"error":{"message":"(#324) Requires 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();
        }

    }

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}}
like image 611
Akanksha Rathore Avatar asked Mar 15 '13 09:03

Akanksha Rathore


People also ask

What is the meaning of this error message?

An error message is a message displayed to the user by an operating system or application when an unexpected condition happens. In most cases, error messages are displayed with the help of dialog boxes by the operating system or application.

What is the cause of error message?

Error messages are used when user intervention is required, to indicate that a desired operation has failed, or to relay important warnings (such as warning a computer user that they are almost out of hard disk space).

What are the three causes of error messaging?

A good error message has three parts: problem identification, cause details if helpful, and a solution if possible. Whenever an error occurs, user wants to fix it as soon as possible.


1 Answers

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.

like image 150
Ming Li Avatar answered Oct 19 '22 05:10

Ming Li