Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android {quot;error";:{quot;message";:“(#324)需要上传文件”,类型:“:”OAutheException“,”代码“:324}”_Android_Facebook_Image_Post_Types - Fatal编程技术网

Android {quot;error";:{quot;message";:“(#324)需要上传文件”,类型:“:”OAutheException“,”代码“:324}”

Android {quot;error";:{quot;message";:“(#324)需要上传文件”,类型:“:”OAutheException“,”代码“:324}”,android,facebook,image,post,types,Android,Facebook,Image,Post,Types,我的应用程序支持facebook的单点登录。我不想使用对话框。 每当我试图在附件中同时发布图像和消息时,我会发现: private void postToWall(String msg) { Bundle parameters = new Bundle(); // parameters.putString("method", "stream.publish"); JSONObject attachment = new JSONObject();

我的应用程序支持facebook的单点登录。我不想使用对话框。 每当我试图在附件中同时发布图像和消息时,我会发现:

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();
        }

    }

请参阅此处的文档以获取照片图张贴请求


您的图像数据应进入“源”字段,其他可用字段只有“消息”、“地点”和“无新闻报道”。“src”、“name”、“href”是无效字段。

删除此
附件。put(“键入”、“图像”)
删除这一行后,我进行了检查。但仍然得到相同的错误。这仍然是真的吗?我了解到,您可以通过url发布图像,在这种情况下,您可以使用“src”而不是“source”:您可以使用“source”或“url”发布图像。
{"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}