2012-07-16 94 views
-1

在我的Android应用程序中,我使用Facebook Api在他/她的墙上张贴消息。它的工作正常没有任何问题。现在我试图用html链接发布消息。该消息得到张贴在Facebook墙上,但HTML链接不起作用。它看起来像普通文本。这是我试图张贴在faceboook墙上的消息的代码如何使用HTML链接在Facebook墙上发布消息?

private String Facebook = "<a href=https://www.facebook.com/>Facebook</a>"; 

Message = "Hi"+Html.fromHtml(Facebook); 

我是否做错了什么。

编辑

我想有像这样的Facebook墙上

嗨,大家好Facebook是非常好的社交网站。

感谢您的帮助球员。

+0

遗憾的是..刚刚更新的问题 – GoCrazy 2012-07-16 10:05:25

+0

是有可能知道downvote – GoCrazy 2012-07-16 18:33:53

回答

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);  
+0

谢谢您的回答的原因。在这个片段中我想知道'facebook.request(参数)'中的facebook是什么意思..谢谢 – GoCrazy 2012-07-16 10:31:32

+0

Facebook的Facebook =新的Facebook(AppID); – Venky 2012-07-16 10:32:41

+0

事情是我从其他活动发送消息到Facebook活动 – GoCrazy 2012-07-16 10:35:41

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

感谢您的答案..我编辑了我的问题..我只是想在Facebook墙上那样.. – GoCrazy 2012-07-16 13:04:55

相关问题