Facebook comment block does not display in Android web browser

In the HTML file, I used the Facebook Social Comment plugin and it works fine, but when I tried to display the same file in android using webview, then it displays only comments and not the comments field, and it displays the "Login to facebook to post a comment" button " When I tried to login by clicking on this button, instead of showing a comment box; the page is redirected to the facebook profile. Please, help...

Here is the code:

HTML code:

<head> <meta content='website' property='og:type'/> <meta content='http://graph.facebook.com/username' property='fb:admins'/> <meta content='http://example.com/test.html' property='og:site_name'/> <meta content='415944175093180' property='fb:app_id'/> <meta content='Browser Detect' property='og:title'/> <meta content='Tells about Early days' property='og:description'/> <meta content='http://example.com/test.html' property='og:url'/> <meta content='http://example.com/test.html' property='og:image'/> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId: '415944175093180', status: true, cookie: true, xfbml: true,oauth: true}); }; (function() { var e = document.createElement('script'); e.type = 'text/javascript'; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); }()); (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); </script> <fb:comments href="http://example.com/test.html" num_posts="20" width="470" /> </body> 

Android Code:

public class SimpleActivity extends the action {

 WebView web1; ViewPager awesomePager; Context cxt; List<WebView> data; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); cxt = this; data = new ArrayList<WebView>(); awesomePager = (ViewPager) findViewById(R.id.viewPager); awesomePager.setOffscreenPageLimit(10); WebView web1 = new WebView(cxt); web1.loadUrl("http://example.com/test.html"); WebSettings webSettings1 = web1.getSettings(); webSettings1.setJavaScriptEnabled(true); data.add(web1); awesomePager.setAdapter(new AwesomePagerAdapter(this,data)); 

}

+7
source share
1 answer

It is possible that in the "standard" html, using a web browser, the session is somewhat saved, so you are logged in to facebook and you can leave comments as registered users, even if you close the browser and restart it (cookies, "hold me in the account, etc.).

An Android browser, on the other hand, may not cache / save the session, the application may have been killed, etc. Thus, you are less likely to have an โ€œalways on oneโ€ session.

Of course, facebook will recognize this and will present you with a login form because you cannot leave comments as an anonymous user.

An AFAIK solution would be to use the Facebook API instead of logging into Javascript so that your application constantly gets the right to access user data / leave a comment as a registered user.

0
source

All Articles