通过Android在Facebook的朋友的墙/帐户中上传图像
-
12-11-2019 - |
题
我想通过我在Android中的应用程序使用Facebook API将图像上传到我朋友的帐户/墙上。 我能够将图像上传到我的帐户,但现在我正在尝试使其更加奏效,并尝试在我通过我的Android应用程序中读取朋友的墙/帐户上传图像。 我试图这样做,但没有成功。 PLZ帮助我...... 提前谢谢
解决方案
在方法中使用此代码
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();
}
. 其他提示
对Facebook的所有集成使用此链接 它推荐由Facebook开发人员..
http://developers.facebook.com/docs/guides/mobile/android_hackbook/
问候...... mehul patel
不隶属于 StackOverflow