Is it possible to put a Facebook like button in a mobile app and when used, it would like my website url?

守給你的承諾、 提交于 2020-01-06 07:35:10

问题


I have an Android and an iPhone mobile app into which I need to put a Facebook like button for marketing purposes.

The problem is that I am not sure what is really being liked when a user likes something from inside a mobile app. I have a website for the two apps (Android and iPhone) so it seems that this website should be liked when a user likes something from a mobile app.

Is that possible to do?


回答1:


From my experience and what i know, Facebook doesn't leave you the possibility to use a likeButton into a mobil Application, they don't want the users to be spammed by those in every apps.

From my point of view, there is two solutions, but neither are perfect :

  • You use Facebook OpenGraph and create a like action for a Website Object, you can find more informations about Facebook OpenGraph on facebook documentation, OpenGraph web tutorial and the last one examples that are more specific to iOS. But if i remember right, you won't be able to create an action called "Like", i think facebook will prevent it so there is no confusion for the users, but as i'm not sure at all, it's still worth a try.

  • the second solution is to make a simple UIButton, and when you click on it you just show a webview of the facebook page you want the user to like. If you want to know if the user liked your page, you can always make a request for his likes and try to find your facebook page id in it, whenever the user did exit the webview.

I hope i answered your question.

And if ever you find a way to make a real facebook like (not an opengraph), directly in a native mobile application, i would be very interested in knowing the howto.

EDIT:

Actually, only the second solution would work if it's to like a facebook fanpage, as for OpenGraph you need to be able to modify the metadata sent by the page so it fits the properties of your object.

The Opengraph solution would work only to make a fake "like" on a webpage of your own.




回答2:


Use this code. You should be logged in to Facebook, before using this code. Check whether the Facebook session is valid and then use this code.

WebView foll_fb = (WebView) findViewById(R.id.btn_foll_fb);    
String url = "http://www.facebook.com/plugins/like.php?layout=standard&show_faces=true&width=80&height=50&action=like&colorscheme=light&href=YOUR_URL_TO_LIKE";              
foll_fb.loadUrl(url);
foll_fb.getSettings().setJavaScriptEnabled(true);
foll_fb.requestFocus(View.FOCUS_DOWN);
foll_fb.setWebViewClient(new LikeWebviewClient());



回答3:


Correct. If you click a like button inside a mobile app, most users expect that they have liked the corresponding page. If you have a page for both the android and the iOS app, then it should like the corresponding one.

In case you wanted to know how to do this, I can give you the main idea. Simply place a button, that on tap, runs whatever is necessary to like something. Since I personally haven't done that, I'm not sure what needs to be run.

Hope that helps, but someone else probably has a better answer than I do. Meaning the actual code to that.



来源:https://stackoverflow.com/questions/13476898/is-it-possible-to-put-a-facebook-like-button-in-a-mobile-app-and-when-used-it-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!