Advertisement
Guest User

Facebook Force Share to view

a guest
Dec 29th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html
  3. xmlns:fb="http://www.facebook.com/2008/fbml"
  4. xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta content="text/html; charset=UTF-8"
  7. http-equiv="Content-Type">
  8. <title></title>
  9. </head>
  10. You can use javascript to do anything you can think of depending on if the user shares or does not. In this example if the user shares they are ridirected to your landing page with this code:
  11.  
  12. window.location = "http://www.REDIRECT-AFTER-SHARE.com";
  13.  
  14. or alerted to share before viewing with this code:
  15.  
  16. alert('You must share this to view content');
  17.  
  18. Let me know if you guys like this stuff and I will post many more in the future!
  19. Says to edit this too...
  20.  
  21. function(response) { if (response && response.post_id) { window.location = "http://www.REDIRECT-AFTER-SHARE.com"; } else { alert('You must share this to view content'); streamPublish(); }
  22.  
  23.  
  24.  
  25.  
  26. <body>
  27.  
  28. Add content HERE!
  29.  
  30. <div id="fb-root" class="fb_reset">
  31. <script type="text/javascript">
  32. //hd
  33. window.fbAsyncInit = function() {
  34. FB.init({appId: 'APP ID', status: true, cookie: true, xfbml: true});
  35. FB.Event.subscribe('edge.create', function(href, widget) {
  36. document.getElementById('share').style.display = "block";
  37. document.getElementById('liked').style.display = "none";
  38. });
  39. /* All the events registered */
  40. FB.Event.subscribe('auth.login', function(response) {
  41. // do something with response
  42. });
  43. FB.getLoginStatus(function(response) {
  44. if (response.session) {
  45. // logged in and connected user, someone you know
  46. }
  47. });
  48. };
  49. (function() {
  50. var e = document.createElement('script');
  51. e.type = 'text/javascript';
  52. e.src = document.location.protocol +
  53. '//connect.facebook.net/en_US/all.js';
  54. e.async = true;
  55. document.getElementById('fb-root').appendChild(e);
  56. }());
  57. function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){
  58. FB.ui(
  59. {
  60. method: 'stream.publish',
  61. message: '',
  62. attachment: {
  63. name: 'Top Blue Linkable Text Shared On user Wall',
  64. caption: 'Add Caption Text Here',
  65. description: ('Site Description HERE'),
  66. href: 'http://www.YOUR-SITE.com',
  67. media: [{ 'type': 'image', 'src': 'http://IMAGE-URL.com', 'href':'http://www.YOUR-SITE.com'}],
  68. href: 'http://www.YOUR-SITE.com'
  69. },
  70. action_links: [
  71. { text: 'Add action Link text', href: 'www.YOUR-SITE.com' }
  72. ],
  73. user_prompt_message: 'Message text'
  74. },
  75. function(response) {
  76. if (response && response.post_id) {
  77. window.location = "http://www.REDIRECT-AFTER-SHARE.com";
  78. } else {
  79. alert('You must share this to view content');
  80. streamPublish();
  81. }
  82. });
  83. }
  84. </script>
  85. <center>
  86. <p align="center"></p>
  87. <p align="center">
  88. <img onclick="streamPublish()"
  89. src="IMAGE-CLICKED-FOR-POPUP.gif" border="0"></p>
  90. <div
  91. style="position: relative; width: 400px; height: 100px;">
  92. <div>
  93. </div>
  94. </div>
  95. </center>
  96. </div>
  97. </body>
  98. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement