3

Facebook ページのビジネスに写真をアップロードし、その写真にユーザーをタグ付けできるアプリを開発しています。

私の問題は、写真がうまくアップロードされていることですが、写真にタグを付けようとすると、Facebook ページに表示されず、写真の情報ではタグが存在することを示していますが、「要求されたタグ」というメッセージが表示されます。

これは要約された私のコードです:

FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,
        BinaryAttachment.with("photo.jpg", readImagen(this.namePhoto)),
        Parameter.with("message",this.message));

    String photoId= publishPhotoResponse.getId();

    try {
        String relativePath = photoId + "/tags/" + userId;

        StringBuilder sb = new StringBuilder("access_token=");
        sb.append(URLEncoder.encode(token_user, "UTF-8"));
        sb.append("&x=");
        sb.append(URLEncoder.encode("50", "UTF-8"));
        sb.append("&y=");
        sb.append(URLEncoder.encode("50", "UTF-8"));

        URL url = new URL("https://graph.facebook.com/"+relativePath);
        HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
        httpCon.setDoOutput(true);
        httpCon.setRequestMethod("POST");
        httpCon.setRequestProperty("Content-Type", "multipart/form-data");
        httpCon.setRequestProperty("Content-Length", "" + sb.toString().length());

        OutputStreamWriter out = new OutputStreamWriter( httpCon.getOutputStream());
            out.write(sb.toString());
            out.flush();

                System.out.println(httpCon.getResponseCode());
                System.out.println(httpCon.getResponseMessage());
            System.out.println(sb.toString());
            System.out.println(out.getEncoding());
            System.out.println(out.toString());
            System.out.println("url : "+url);

    } catch (IOException ex) {
            System.out.println(ex);

    }

コンソールに次の情報が表示されます。

500
Internal Server Error
access_token=XXXXXXXXXX....XXXX..X&x=50&y=50
UTF8
java.io.OutputStreamWriter@1eb13dc
url : https://graph.facebook.com/XXXXXXXXXXXXX/tags/XXXXXXXXXXXXX

500エラーによると、エラーは私のものではないようですが、おそらく私はそれを正しく行っていません。誰かが私を助けることができますか?

4

0 に答える 0