Android的Facebook的喜欢喜欢、Android、Facebook

2023-09-13 00:48:25 作者:樱花树下如谎的誓言

我想在我的Andr​​oid应用程序集成了一个类似按钮。我用code

  likeWebView =(web视图)findViewById(R.id.webView1);
 likeWebView.getSettings()setJavaScriptEnabled(真)。
 字符串URL =htt​​p://www.facebook.com/plugins/like.php? +
           的href =+ URLEn coder.en code(likeurl)+&放大器; +
           布局=标准和放大器; +
           show_faces =假放; +
           WIDTH = 500安培; +
           行动=像和放大器; +
           色彩方案=光&安培; +
           access_token =+ URLEn coder.en code(read_stream);
likeWebView.loadUrl(URL);
 

但它显示一个空白页面登录后。 请给我一个解决方案,添加一个Like按钮。

解决方案

 私人initLikeButton(字符串urlToLike){
   likeWebView =(web视图)findViewById(R.id.likeWebView);
   likeWebView.getSettings()setJavaScriptEnabled(真)。

字符串URL =htt​​p://www.facebook.com/plugins/like.php? +
       的href =+ URLEn coder.en code(urlToLike)+&放大器; +
       布局=标准和放大器; +
       show_faces =假放; +
       WIDTH = 375安培; +
       行动=建议和放大器; +
       色彩方案=光&安培; +
       access_token =+ URLEn coder.en code(FacebookAdapter.getInstance()getAccessToken());

likeWebView.loadUrl(URL);
 

下面,在你的code,你必须把 likeurl ,网址喜欢。

利用类似按钮code发生器提供的iframe code在http://developers.facebook.com/docs/reference/plugins/like.但由于一个iframe基本上是同样的事情作为一个web视图,它似乎是多余加载的iframe的code,然后加载的iframe的web视图。所以不是我刚装了code,这将是在iframe直接进入使用下面的code中的web视图。但同样的事情发生两种方式。

顺便说一句,开发一个iPhone应用程序时存在同样的问题。我们不希望用户必须登录Facebook的每次运行我们的应用程序的时间。但不幸的是,如果用户已经登录到Facebook上,因为他们最后一次登录通过我们的应用程序,Facebook的另一台电脑,他们就必须重新登录。

Facebook升级Android客户端 力求与iOS同步

在Android平台上,我觉得一个更好的解决办法可能是让您发送的意图,这需要保持用户登录并返回的HTML渲染类似按钮的照顾一个Facebook应用程序。

看多:https://github.com/facebook/facebook-android-sdk/issues/17

http://blog.doityourselfandroid.com/2011/02/28/30-minute-guide-integrating-facebook-android-application/

http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/

integrate Facebook的在Android和iPhone 像按钮

I want to integrate a like button in my android app. I used the code

likeWebView = (WebView) findViewById( R.id.webView1 );
 likeWebView.getSettings().setJavaScriptEnabled(true);
 String url = "http://www.facebook.com/plugins/like.php?" +
           "href=" + URLEncoder.encode("likeurl" ) + "&" +
           "layout=standard&" +
           "show_faces=false&" +
           "width=500&" +
           "action=like&" +
           "colorscheme=light&" +
           "access_token=" + URLEncoder.encode( "read_stream" );
likeWebView.loadUrl( url );

But after login it is showing a blank page. Please give me a solution to add a Like button.

解决方案

private initLikeButton( String urlToLike ) {
   likeWebView = (WebView) findViewById( R.id.likeWebView );
   likeWebView.getSettings().setJavaScriptEnabled(true);

String url = "http://www.facebook.com/plugins/like.php?" +
       "href=" + URLEncoder.encode( urlToLike ) + "&" +
       "layout=standard&" +
       "show_faces=false&" +
       "width=375&" +
       "action=recommend&" +
       "colorscheme=light&" +
       "access_token=" + URLEncoder.encode( FacebookAdapter.getInstance().getAccessToken() );

likeWebView.loadUrl( url );

Here, in your code you must be put likeurl , url that like.

using the iframe code provided by the like button code generator at http://developers.facebook.com/docs/reference/plugins/like. But since an iframe is basically the same thing as a WebView, it seemed redundant to load the code in an iframe and then load the iframe in a WebView. So instead I just loaded the code that would be in the iframe directly into the WebView using the code below. But the same thing happens either way.

Incidentally, the same issue exists when developing an iPhone app. We don't want the user to have to login to facebook every time they run our app. But unfortunately, if the user has logged into facebook on another computer since the last time they logged into facebook via our app, they'll have to log in again.

On the android platform I would think a better solution might be to have a facebook app that you send an intent to that takes care of keeping the user logged in and returning the html for rendering the like button.

see more: https://github.com/facebook/facebook-android-sdk/issues/17

http://blog.doityourselfandroid.com/2011/02/28/30-minute-guide-integrating-facebook-android-application/

http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/

integrate facebook with like button in android and iphone