Android的:如何张贴在墙上的朋友用Android SDK中的照片/视频? [英] Android : How to post Photo/Video on friend wall with android sdk?

查看:207
本文介绍了Android的:如何张贴在墙上的朋友用Android SDK中的照片/视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过了这个例子:<一href=\"http://stackoverflow.com/questions/6688957/android-how-to-post-picture-to-friends-wall-with-facebook-android-sdk\">Android如何上传图片朋友的墙与Facebook Android SDK中

但不起作用。这里是我的code:

but not work. here is my code :

String response = Utility.mFacebook.request((userID == null) ? "me" : userID);

            final Bundle params = new Bundle();
            params.putString("message", "test");
            params.putString("caption", "test");
            params.putString("picture", "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");

            response = Utility.mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");

任何样品code对朋友墙,能交视频/照片?

Any sample code that able post video/photo on friend wall?

推荐答案

这是我用它来发布图片到墙壁的方法,它从一个网址张贴事先知情同意,但你可以改变它把一个byte []为知情同意代替。出现在图像上方的消息和字幕出现在画面的右侧。

This is the method i use to post a picture to a wall, it posts a pic from a URL but you can change it to put a byte[] for the pic instead. The message appears above the picture and the caption appears to the right of the picture.

protected void postPicToWall(String userID, String msg, String caption, String picURL){
    try {
        if (isSession()) {
            String response = mFacebook.request((userID == null) ? "me" : userID);

        Bundle params = new Bundle();
        params.putString("message", msg);  
        params.putString("caption", caption);
        params.putString("picture", picURL);

        response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");       

        Log.d("Tests",response);
        if (response == null || response.equals("") || 
                response.equals("false")) {
            Log.v("Error", "Blank response");
        }
    } else {
        // no logged in, so relogin
        Log.d(TAG, "sessionNOTValid, relogin");
        mFacebook.authorize(this, PERMS, new LoginDialogListener());
    }
}catch(Exception e){
    e.printStackTrace();
    }
}

要发布到PIC一个byte [],而不是一个URL,则替换该行

To post a byte[] rather than a url to a pic then replace the line

params.putString(图片报,picURL);以

params.putString("picture", picURL); with

params.putByteArray(图片,getIntent()getExtras()getByteArray(数据));

params.putByteArray("picture", getIntent().getExtras().getByteArray("data"));

其中的数据阵列。

这篇关于Android的:如何张贴在墙上的朋友用Android SDK中的照片/视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆