User must like page before viewing

删除回忆录丶 提交于 2019-12-08 15:35:04

问题


I have struggled with this for quite some time now but figured I would revisit the issue. My goal is to do the same type of thing This facebook page is doing https://www.facebook.com/JimBeam?sk=app_140011936063255

They have made it so that the user must click the like button before reviewing the content.

My normal procedure is to build a welcome.HTML page, create a new app on fb, then assign page to the correct business.

My question is if I designed a new html page, let's call it pre-like.HTML, where would I drop in the code so that this page design displays prior to users being able to see the welcome page?

I guess once the like button is clicked it would redirect users to the welcome page? I would greatly appreciate any advice or good tutorials you could send my way on doing this.

Thank you in advance!!


回答1:


I found this information for you. FACEBOOK SECRET HIDE CONTENT ON FAN PAGE UNTIL SOMEONE LIKES IT

you need to add this in the part of your PHP file you want to display a different message for non fans and fans.

 <?php

 $request = $_REQUEST["signed_request"];</p>
 <p>list($encoded_sig, $load) = explode('.', $request, 2);</p>
 <p>$fbData = json_decode(base64_decode(strtr($load, '-_', '+/')), true);</p>
 <p>if (!empty($fbData["page"]["liked"]))</p>
 <p>{ ?></p>
 <p>You are a fan - insert html here</p>
 <p><?php } else { ?></p>
 <p>You are not a fan - insert html here</p>
 <p>

 <?php } ?>

Hope that helps! I strongly recommend you hit the link I sourced the info from and go follow his directions. The article is dated from October, so I think this might the most recent info out there on the web.




回答2:


When the user opens your app, facebook does a post request (via a hidden form) to your application's canvas url. It contains a signed_request parameter, that you can verify with your app secret, then decode. It contains some info about the user even before he/she adds your app, and it also has whether he/she liked the page the app is in.

See the documentation of the signed request parameter for more detailed information and also a php example of verifying/decoding it.

It's a bit hidden, but you'll need to test $decoded_data->page->liked, it's possibly enough to be included in your landing page.




回答3:


I would check on the server when you get the request for the welcome page. That way you know you are getting the correct information. If they have't liked the page, send them back to the landing page, otherwise allow them to see the welcome page.



来源:https://stackoverflow.com/questions/7858141/user-must-like-page-before-viewing

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