0

これは、Facebook の壁に画像を投稿するためのコードで、正常に完了しました。 but image is not saved in photos on facebook album and it is too small.

     Bundle b = new Bundle();
     b.putString("picture", imageurl); // imageurl ="http://bks6.books.google.ca/books?id=5VTBuvfZDyoC&printsec=frontcover&img=1&+zoom=5&edge=curl&source=gbs_api" 
     b.putString("caption","This is deme");
     b.putString("description","Download " );
     b.putString("name","Demo Name");
     b.putString("message","Download  www.google.com \n  Vote For tp://abc.com");
     b.putString("link","WWW.google.com");  // demo link
     String strRet = fb.request("/me/feed",b,"POST");

My image should look like thisしかし、それは起こっていません。私はbig size以下の画像を参照してください。.

ここに画像の説明を入力

私が見た画像を見てくださいposted on wall its too small and its not saved in album. ここに画像の説明を入力

私を助けてください ..

4

2 に答える 2

2

以下のパラメータを追加します。

b.putString("method", "photos.upload");
//..other extras

次の行を置き換えます

fb.request("/me/feed",b,"POST");

fb.request(null, b, "POST");

以下は完全なコードです。

FileInputStream fis;
try {
    DefaultHttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet(imageUrl);
    HttpResponse response = client.execute(request);
    HttpEntity entity = response.getEntity();
    int imageLength = (int)(entity.getContentLength());
    InputStream is = entity.getContent();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    byte[] b = new byte[1024];
    int bytesRead;
    while ((bytesRead = is.read(b)) != -1) {
        baos.write(b, 0, bytesRead);
    }
    data = baos.toByteArray();

    Bundle params = new Bundle();
    params.putString(Facebook.TOKEN, facebook.getAccessToken());
    params.putString("method", "photos.upload");
    params.putByteArray("picture", data);
    params.putString("caption",
            "your Caption\nYour Caption");

    String resp = facebook.request(null, params, "POST");
}
于 2013-06-17T06:16:43.840 に答える
0

誰かのウォールではなくアルバムに画像をアップロードするべきだと思います(あなたがやっているように)。

これを試してください: (この例は Java ではなく PHP であることに気付きました... Java サンプルを掘り下げることができるかどうかを確認します)。 https://developers.facebook.com/blog/post/498/

編集: これは Android のサンプルです: http://sunnysharma4android.blogspot.com/

于 2013-06-17T06:10:46.590 に答える