0

This is my code to post image on my facebook wall its done successfully. 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 but its not happening. i mean in big size.see bellow image. .

enter image description here

see the image which i posted on wall its too small and its not saved in album. enter image description here

please help me ..

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

我相信您应该将图像上传到某人的相册而不是他们的墙上(就像您正在做的那样)。

试试这个:(我意识到这个例子是php,而不是java......我会看看我是否可以挖掘java样本)。 https://developers.facebook.com/blog/post/498/

编辑:这是一个 Android 示例: http ://sunnysharma4android.blogspot.com/

于 2013-06-17T06:10:46.590 回答