在我的Android应用程序中,我使用Facebook Api在他/她的墙上发布消息。它的工作正常没有任何问题。现在我尝试在其中发布带有html链接的消息。该消息发布在Facebook墙上,但HTML链接无法正常工作。它看起来像普通文本。这是我试图在faceboook墙上发布的代码
的消息private String Facebook = "<a href=https://www.facebook.com/>Facebook</a>";
Message = "Hi"+Html.fromHtml(Facebook);
我做错了什么。
修改
我想在facebook墙上有这样的想法
嗨,EveryOne Facebook是一个非常好的社交网站。
感谢您的帮助。
答案 0 :(得分:0)
尝试使用此代码段添加html链接:
Bundle parameters = new Bundle();
JSONObject attachment = new JSONObject();
try {
attachment.put("message", "Messages");
attachment.put("name", "Message");
attachment.put("href", "http://www.facebook.com");
} catch (JSONException e) {}
parameters.putString("attachment", attachment.toString());
facebook.request(parameters);
答案 1 :(得分:0)
// put this code in your button click event listener
facebook = new Facebook("your facebook id");
mAsyncRunner = new AsyncFacebookRunner(facebook);
facebook.authorize(this, new String[]
{ "publish_stream", "offline_access" }, -1,
new DialogListener()
{
public void onComplete(Bundle values)
{
Log.e("tag", "Values returned by Bundle ====> " + values.toString());
fbImageSubmit(facebook, "", "caption", "description", "name", "www.google.com");
}
public void onFacebookError(FacebookError error)
{
}
public void onError(DialogError e)
{
}
public void onCancel()
{
}
});
//add method into your class
private void fbImageSubmit(Facebook fb, String imageurl, String caption, String description, String name, String linkurl)
{
if (fb != null)
{
if (fb.isSessionValid())
{
Bundle b = new Bundle();
// b.putString("picture", "");
b.putString("caption", "");
b
.putString(
"description",
"test");
b.putString("name", "Hi Friends, I am using the your app name app for Android!");
b.putString("link", "https://market.android.com/details?id="+this.getApplication().getPackageName().toString());
try
{
String strRet = "";
strRet = fb.request("/me/feed", b, "POST");
JSONObject json;
try
{
json = Util.parseJson(strRet);
if (!json.isNull("id"))
{
Log.i("Facebook", "Image link submitted.");
}
else
{
Log.e("Facebook", "Error: " + strRet);
}
} catch (FacebookError e)
{
Log.e("Facebook", "Error: " + e.getMessage());
}
} catch (Exception e)
{
Log.e("Facebook", "Error: " + e.getMessage());
}
}
}
}