Fazendo upload de imagem no mural/conta de um amigo no Facebook através do Android

StackOverflow https://stackoverflow.com/questions/5978498

  •  12-11-2019
  •  | 
  •  

Pergunta

Quero fazer upload de uma imagem para a conta/mural do meu amigo usando a API do Facebook por meio do meu aplicativo no Android.Consigo fazer upload da imagem para minha conta, mas agora estou tentando torná-la mais funcional e tentando fazer upload da imagem no mural/contas de amigos que estou selecionando por meio de meu aplicativo Android.Eu tentei fazer isso, mas sem sucesso.Por favor me ajude...Desde já, obrigado

Foi útil?

Solução

Use este código no seu método

File file=new File(murl);
InputStream is;
try {
    is = new FileInputStream(file);
    Drawable d;
    long length = file.length();
    if (length > Integer.MAX_VALUE) {
        // File is too large
    }
    byte[] bytes = new byte[(int)length];
    ByteArrayOutputStream bout=new    ByteArrayOutputStream();
    // Read in the bytes
    int offset = 0;
    int numRead = 0;
    while (offset < bytes.length
           && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
        offset += numRead;       
    }
    bout.write(bytes);
    bout.flush();
    //Bitmap bm=BitmapFactory.decodeByteArray(bytes,0,bytes.length);
    //d=new BitmapDrawable(bm);
    //mPostButton.setBackgroundDrawable(d);
    //p.putString("to","1300750213");
    //p.putString("caption","my card");
    EditText title_txt=(EditText) findViewById(R.id.fb_upload_txt);

    for(int i =0;i<frnd_list_id.length/2;i++){
        if(frnd_list_id[i]!="0"){
            Bundle p=new Bundle();
            p.putString("method","photos.upload");
            p.putString("caption",title_txt.getEditableText().toString());
            p.putByteArray("picture",bytes);
            System.out.println(frnd_list_id[i].trim());
            p.putString("target_id",frnd_list_id[i].trim());
            mAsyncRunner.request(null,p,"POST",new WallPostRequestListener(),null);
        }
    }
//System.out.println("hi");
} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Outras dicas

Use este link para toda a integração do Facebook É recomendado pelo desenvolvedor do Facebook ..

http://developers.facebook.com/docs/guides/mobile/android_hackbook/

Atenciosamente ... Mehul Patel

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top