简体   繁体   English

Android Facebook API供稿对话框?

[英]Android Facebook API feed dialog?

Ok so I have setup a new Facebook app and I have the API and all that jazz setup also and have made successful posts to Facebook using the API. 好的,所以我已经设置了一个新的Facebook应用程序,并且拥有了API和所有爵士设置,并且已经使用该API成功发布到了Facebook。 Here is my issue. 这是我的问题。

How do I format the text the way I want too?? 如何以我想要的方式设置文本格式?

For example: 例如:

description += "First line \r\n";
description += "Second line \r\n";

I am using the Facebook Android SDK and using the Feed Dialog approach as listed here 我正在使用Facebook Android SDK并使用此处列出的Feed对话框方法

Also, I am using the feed dialog like so: 另外,我正在使用供稿对话框,如下所示:

String description += "First line \r\n";
description += "Second line \r\n";
Facebook facebook = new Facebook("MY_APP_ID");
SetAccessToken(mContext, facebook);
params.putString("link", "");
params.putString("picture", "");
params.putString("name", "");
facebook.dialog(mContext, "feed", params, new Facebook.DialogListener() {

public void onFacebookError(FacebookError e) {

}

public void onError(DialogError e) {

}

public void onComplete(Bundle values) {

}

public void onCancel() {

}
});

Whenever, I do that it pulls up my Facebook dialog and the lines are not separated by line feeds. 每当我这样做时,它都会弹出我的Facebook对话框,并且各行之间不使用换行符分隔。 I also tried to use HTML such as 我也尝试使用HTML,例如

<p>Line 1</p>
<p>Line 2</p>

My guess is that I need to use another method in order to actually post formatted text, other than the feed dialog. 我的猜测是,除了供稿对话框外,我还需要使用另一种方法来实际发布格式化的文本。 I know that other Facebook apps are posting to users feeds with properly formatted text. 我知道其他Facebook应用程序正在使用正确格式的文本向用户供稿发布。 Just not sure why the SDK doesn't offer the same functionality. 只是不确定为什么SDK不提供相同的功能。

EDIT 1 编辑1

Just to add this, the submission is actually in a URL format at the end anyway. 只是要添加此内容,无论如何,提交实际上是末尾的URL格式。 I tried adding URL escape characters but that didn't seem to do anything for me. 我尝试添加URL转义字符,但这似乎对我没有任何帮助。

String url = endpoint + "?" + Util.encodeUrl(parameters);

Then they pass that into a webview. 然后,他们将其传递到网络视图中。 So I am currently looking into this. 所以我目前正在调查。 Any advice is appreciated. 任何建议表示赞赏。

as far as I have researched...facebook doesn't allow it's domain image to be posted on wall through post. 据我研究... facebook不允许将其域名图片通过帖子张贴在墙上。 So, we can't use it. 因此,我们不能使用它。 Now what I am doing is getting the imge through following code: 现在,我正在通过以下代码获取图像:

ImageView user_picture;
        user_picture = (ImageView) findViewById(R.id.user_picture);
        URL img_value = null;
        Bitmap mIcon1 = null;
        try {
            img_value = new URL("http://graph.facebook.com/XXXX/picture");
            try {
                mIcon1 = BitmapFactory.decodeStream(img_value
                        .openConnection().getInputStream());
            } catch (IOException e) {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            }
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if(mIcon1!=null){
            user_picture.setImageBitmap(mIcon1);
        }

if you want it to convert to byte array 如果您希望将其转换为字节数组

 ByteArrayOutputStream baos = new ByteArrayOutputStream();   
        mIcon1.compress(Bitmap.CompressFormat.PNG, 100, baos);    
        b = baos.toByteArray(); 

Sending this image to my server and then posting to wall. 将此图像发送到我的服务器,然后发布到墙上。

Have you tried: 你有没有尝试过:

String message = "<p>Line 1</p><p>Line 2</p>";
params.putString("message", Html.fromHtml(message).toString());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM