通过Android上传朋友墙/Facebook帐户中的图像

发布于 2024-11-06 18:42:33 字数 155 浏览 0 评论 0原文

我想使用 Facebook Api 通过我在 android 中的应用程序将图像上传到我朋友的帐户/墙。 我可以将图像上传到我的帐户,但现在我正在尝试使其更具功能性,并尝试将图像上传到我通过 Android 应用程序选择的朋友的墙/帐户上。 我尝试过这样做,但没有成功。 请帮帮我... 提前致谢

I want to upload an image to my friend's account/wall using Facebook Api Through My application in android.
I am able to upload the image to my account, but now I am trying to make it more functional and trying to upload the image on friend's wall/accounts which I am selecting through my Android Application.
I have tried to do it but no success.
Plz help me...
Thanks in Advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫多说 2024-11-13 18:42:33

在您的方法中使用此代码

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();
}

Use this code in your method

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();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文