Guest User

fb_index

a guest
Jan 17th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.34 KB | None | 0 0
  1. <?php
  2. //Enter your APP ID below
  3. define("266872970045582","1a");
  4. define("266872970045582","2a");
  5. define("266872970045582","3a");
  6. define("266872970045582","4a");
  7. ?>
  8. <!-- Copyright 2004-2011 Facebook. All Rights Reserved.-->
  9.  
  10. <html xmlns="http://www.w3.org/1999/xhtml"
  11.  xmlns:fb="http://www.facebook.com/2008/fbml">
  12. <head>
  13.   <title>Der Maya-Kalender - Countdown zum 21.12.2012</title>
  14.   <link rel="stylesheet" href="facebook.css" type="text/css" media="screen" />
  15. </head>
  16.  
  17. <body>
  18. <?php
  19. include 'libs/facebook.php';
  20.  
  21. $facebook = new Facebook(array(
  22.     'appId' => '266872970045582',
  23.     'secret' => '7d6fa5183c71ed9a9da9fc840bbbc6d8',
  24.     'cookie' => true
  25. ));
  26. $session = $facebook->getUser();
  27. $me = null;
  28. if($session)
  29. {
  30.     try
  31.     {
  32.         $friends = $facebook->api('/me/friends');
  33.         $me = $facebook ->api('/me');
  34.     }
  35.     catch(FacebookApiException $e)
  36.     {
  37.         echo $e->getMessage();
  38.     }
  39. }
  40.  
  41. if($me)
  42. {
  43. $logoutUrl = $facebook->getLogoutUrl();
  44. echo "<a href='$logoutUrl'>Logout</a>";
  45. }
  46. else
  47. {
  48. $loginUrl = $facebook->getLoginUrl();
  49. echo "<a href='$loginUrl'>Login</a>";
  50. }
  51.  
  52. ?>
  53.  
  54. <div id="fb-root"></div>
  55. <script> // FACEBOOK INITIALIZE
  56.   window.fbAsyncInit = function() {
  57.     FB.init({
  58.       appId      : '266872970045582', // App ID
  59.       channelUrl : '//smaug.nuro.local/mayacalendar/channel.html', // Channel File
  60.       status     : true, // check login status
  61.       cookie     : true, // enable cookies to allow the server to access the session
  62.       xfbml      : true  // parse XFBML
  63.       oauth      : true
  64.      
  65.        FB.Event.subscribe('auth.authResponseChange', handleResponseChange);  
  66.     });
  67.  
  68.      function handleResponseChange(response) {
  69.    document.body.className = response.authResponse ? 'connected' : 'not_connected';
  70.  
  71.    if (response.authResponse) {
  72.      console.log(response);
  73.      updateUserInfo(response);
  74.    }
  75.  }
  76.     // Additional initialization code here
  77.   };
  78.  
  79.    function loginUser() {    //Login
  80.      FB.login(function(response) { }, {scope:'email'});    
  81.      }
  82.      
  83.   // Load the SDK Asynchronously
  84.   (function(d){
  85.      var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
  86.      js = d.createElement('script'); js.id = id; js.async = true;
  87.      js.src = "//connect.facebook.net/en_US/all.js";
  88.      d.getElementsByTagName('head')[0].appendChild(js);
  89.    }(document));
  90.    
  91.     //// SUBSCRIBE - BUTTOM - FUNKTIONSDEFINITIONEN. - EVENT - HANDLER///////////////
  92.     FB.Event.subscribe('edge.create',
  93.     function(response) {
  94.         alert('You liked the URL: ' + response);
  95.     }
  96.     );
  97.     //// SUBSCRIBE - BUTTOM - FUNKTIONSDEFINITIONEN. ///////////////
  98.     FB.Event.subscribe('auth.authResponseChange', function(response) {
  99.     alert('The status of the session is: ' + response.status);
  100.     });
  101.    
  102.     // Attach the handler using FB.Event.subscribe
  103.     FB.Event.subscribe('edge.create', handleResponse(response));
  104.  
  105.     // Function to handle the response
  106.     var handleResponse = function(response) {
  107.        alert ('You liked the URL: ' + response);
  108.     };
  109.  
  110.     // At some point, you no longer want to be notified, and unsubscribe
  111.     FB.Event.unsubscribe('edge.create', handleResponse);
  112.    
  113.     </script>
  114.  
  115.     <h3 align="center"> Purchase Credits</h3>
  116.  
  117.  
  118.     <!--<form name ="oder_body" id="order_form" action="#">
  119.     <img src="http://www.facebook.com/images/gifts/21.png">
  120.     <input type="hidden" name="item_id" value="1a" id="item_id">
  121.     <img src="http://developers.facebook.com/attachment/credits_sm.png"
  122.       height="25px">
  123.     </form>-->
  124.    
  125.     <a name="1Monat" id="item_id1" value="1a">
  126.     <input id="showBuyItem1" type="image" src="http://www.facebook.com/images/credits/paybutton.png">
  127.     <input type="hidden" name="title" id="title_id" value="1monat">
  128.     <input type="hidden" name="price" id="price_id" value="1">
  129.     <input type="hidden" name="description" id="desc_id" size="64" value="1-Monat Packet des Maya Kalendar's">
  130.     <input type="hidden" name="expire" id="expire_id" value="30-11-2012">
  131.     <!--<input type="hidden" name="image_url" id="img_id" size="64" value="">-->
  132.     1-Month-Package
  133.     </a><br>
  134.    
  135.     <a name="3Monate" id="item_id" value="2a">
  136.     <input id="showBuyItem2" type="image" src="http://www.facebook.com/images/credits/paybutton.png">
  137.     <input type="hidden" name="title" id="title_id" value="3monat">
  138.     <input type="hidden" name="price" id="price_id" value="1">
  139.     <input type="hidden" name="description" id="desc_id" size="64" value="3-Monate Packet des Maya Kalendar's">
  140.     <input type="hidden" name="expire" id="expire_id" value="30-09-2012">
  141.     <!--<input type="hidden" name="image_url" id="img_id" size="64" value="">-->
  142.     3-Month-Package
  143.     </a><br>
  144.    
  145.     <a name="6Monate" id="item_id" value="3a">
  146.     <input id="showBuyItem3" type="image" src="http://www.facebook.com/images/credits/paybutton.png">
  147.     <input type="hidden" name="title" id="title_id" value="6monat">
  148.     <input type="hidden" name="price" id="price_id" value="1">
  149.     <input type="hidden" name="description" id="desc_id" size="64" value="6-Monate Packet des Maya Kalendar's">
  150.     <input type="hidden" name="expire" id="expire_id" value="30-06-2012">
  151.     <!--    <input type="hidden" name="image_url" id="img_id" size="64" value="">-->
  152.     6-Month-Package
  153.     </a><br>
  154.    
  155.     <a name="12Monate" id="item_id" value="4a">
  156.     <input id="showBuyItem4" type="image" src="http://www.facebook.com/images/credits/paybutton.png">
  157.     <input type="hidden" name="title" id="title_id" value="12monat">
  158.     <input type="hidden" name="price" id="price_id" value="1">
  159.     <input type="hidden" name="description" id="desc_id" size="64" value="12-Monate Packet des Maya Kalendar's">
  160.     <input type="hidden" name="expire" id="expire_id" value="30-12-2013">
  161.     <!--<input type="hidden" name="image_url" id="img_id" size="64" value="">-->
  162.     Full-Month-Package
  163.     </a><br>   
  164.    
  165.     <a name="getcredits" id="more">
  166.     <input id="showBuyCredits" type="image" src="http://www.facebook.com/images/credits/creditsbutton.png" />  
  167.     Buy Credits
  168.     </a><br>
  169.    
  170.  
  171.     <div id="output"> <?=$html?> </div> </br></br>
  172.     <!--<script>
  173.       FB.init({appId: <?php echo "266872970045582"; ?>, status: true, cookie: true});
  174.  
  175.       function placeOrder() {
  176.  
  177.         // Assign an internal ID that points to a database record
  178.       // var item_id = '1a';
  179.        
  180.         //var item= document.getElementByID('item_id').value;
  181.         var title= document.getElementByID('title_id').value;
  182.         var price = document.getElementById('price_id').value;
  183.         var desc = document.getElementById('desc_id').value;
  184.         var expire = document.getElementById('expire_id').value;
  185.        
  186.         //var img_url = document.getElementById('img_id').value;
  187.        
  188.         //var order_info = item_id;
  189.  
  190.         var oder_info = {
  191.                             "title": title,
  192.                             "price":price,
  193.                             "description":desc,
  194.                             "expire":expire
  195.                             //"img_id":img_url,
  196.                         };     
  197.         //calling the API ...
  198.         var obj = {
  199.         method: 'pay',
  200.         order_info: order_info,
  201.         purchase_type: 'item'
  202.         //dev_purchase_params: {'oscif': false}
  203.         };
  204.  
  205.         FB.ui(obj, callback);
  206.         }
  207.      
  208.        function buyMore(){
  209.  
  210.         // calling the API ...
  211.         var obj = {
  212.           method: 'pay',
  213.           credits_purchase: true
  214.         };
  215.  
  216.         FB.ui(obj, callback);
  217.       }
  218.    
  219.     var callback = function(data) {
  220.       if (data['order_id']) {
  221.         writeback("Transaction Completed! </br></br>"
  222.         + "Data returned from Facebook: </br>"
  223.         + "<b>Order ID: </b>" + data['order_id'] + "</br>"
  224.         + "<b>Status: </b>" + data['status']);
  225.       } else if (data['error_code']) {
  226.         writeback("Transaction Failed! </br></br>"
  227.         + "Error message returned from Facebook:</br>"
  228.         + data['error_message']);
  229.       } else {
  230.         writeback("Transaction failed!");
  231.       }
  232.     };
  233.      
  234.     function writeback(str) {
  235.     document.getElementById('output').innerHTML=str;
  236.     }
  237.  
  238. </script>-->
  239.     <div id="fb-root"></div>
  240.  
  241.         <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
  242.         <script type="text/javascript">
  243.             var jsSdk = window['FB'];
  244.  
  245.             // initialize the SDK
  246.             jsSdk.init({apiKey: '266872970045582', status:true });
  247.  
  248.             /*document.getElementById('showBuyCurrency').onclick = function(){
  249.                 jsSdk.ui({method: 'pay', credits_purchase : false, order_info:'currency.001' },function(){alert('Erfolgreich!')});
  250.                 return false;
  251.             };*/
  252.  
  253.             document.getElementById('showBuyItem1').onclick = function(){
  254.                 jsSdk.ui({method: 'pay', credits_purchase : false, order_info:'item.001' },function(){alert('Erfolgreich!')});
  255.                 return false;
  256.             };
  257.             document.getElementById('showBuyItem2').onclick = function(){
  258.                 jsSdk.ui({method: 'pay', credits_purchase : false, order_info:'item.002' },function(){alert('Erfolgreich!')});
  259.                 return false;
  260.             };
  261.             document.getElementById('showBuyItem3').onclick = function(){
  262.                 jsSdk.ui({method: 'pay', credits_purchase : false, order_info:'item.003' },function(){alert('Erfolgreich!')});
  263.                 return false;
  264.             };
  265.             document.getElementById('showBuyItem4').onclick = function(){
  266.                 jsSdk.ui({method: 'pay', credits_purchase : false, order_info:'item.004' },function(){alert('Erfolgreich!')});
  267.                 return false;
  268.             };
  269.  
  270.             document.getElementById('showBuyCredits').onclick = function(){
  271.                 jsSdk.ui({method: 'pay', credits_purchase : true },function(){alert('Erfolgreich!')});
  272.                 return false;
  273.             };
  274.         </script>
  275.    
  276.    
  277.    
  278.    
  279.     <script>
  280.         (function() {
  281.     var e = document.createElement('script'); e.async = true;
  282.         e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
  283.         document.getElementById('fb-root').appendChild(e);
  284.         }());
  285.     </script>
  286.    
  287.     <?php
  288.     // if $order_id and $status are passed back, we know they were send from the full
  289.     // page view, here we print the same information users see through the normal path
  290.     if ($_GET['order_id'] && $_GET['status']) {
  291.     $html = "Transaction Completed! </br></br>"
  292.       ."Data returned from Facebook: </br>"
  293.       ."<b>Order ID: </b>" . $_GET['order_id'] . "</br>"
  294.       ."<b>Status: </b>" . $_GET['status'];
  295.     } elseif ($_GET['error_code'] && $_GET['error_message']) {
  296.     $html = "Transaction Failed! </br></br>"
  297.       ."Error message returned from Facebook:</br>"
  298.       .$_GET['error_message'];
  299.     }
  300.     ?>
  301.    
  302.     <div id="user-info"></div>
  303.     <script>
  304.     function updateUserInfo(response) {
  305.      FB.api('/me', function(response) {
  306.        document.getElementById('user-info').innerHTML = '<img src="https://graph.facebook.com/' + response.id + '/picture">' + response.name;
  307.      });
  308.     }
  309.  </script>
  310.    
  311. </body>
  312. </html>
Advertisement
Add Comment
Please, Sign In to add comment