22/01/2013, 07:25
|
| | | Fecha de Ingreso: marzo-2008
Mensajes: 120
Antigüedad: 16 años, 1 mes Puntos: 17 | |
Respuesta: Esta aplicacion de facebook es valida? Cita:
Iniciado por vani18 hola , tengo este este codigo que funciona.... es una aplicaicon de facebook...
pero no se si todo lo que contiene es valido... me refiero a lo que es FBML, ya que creo que contiene eso, y el FBML esta obsoleto, no se usa mas... pero FUNCIONA. o tal vez me equivoco.... Código PHP: <?php // Provides access to app specific values such as your app id and app secret. // Defined in 'AppInfo.php' require_once('AppInfo.php'); // Enforce https on production if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') { header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit(); } // This provides access to helper functions defined in 'utils.php' require_once('utils.php'); require_once('sdk/src/facebook.php'); $facebook = new Facebook(array( 'appId' => AppInfo::appID(), 'secret' => AppInfo::appSecret(), 'sharedSession' => true, 'trustForwarded' => true, )); $user_id = $facebook->getUser(); if ($user_id) { try { // Fetch the viewer's basic information $basic = $facebook->api('/me'); } catch (FacebookApiException $e) { // If the call fails we check if we still have a user. The user will be // cleared if the error is because of an invalid accesstoken if (!$facebook->getUser()) { header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI'])); exit(); } } $likes = idx($facebook->api('/me/likes?limit=4'), 'data', array()); // This fetches 4 of your friends. $friends = idx($facebook->api('/me/friends?limit=4'), 'data', array()); // And this returns 16 of your photos. $photos = idx($facebook->api('/me/photos?limit=16'), 'data', array()); // Here is an example of a FQL call that fetches all of your friends that are // using this app $app_using_friends = $facebook->api(array( 'method' => 'fql.query', 'query' => 'SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1' )); } // Fetch the basic info of the app that they are using $app_info = $facebook->api('/'. AppInfo::appID()); $app_name = idx($app_info, 'name', ''); ?> <!DOCTYPE html> <html xmlns:fb="http://ogp.me/ns/fb#" lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=2.0, user-scalable=yes" /> <title><?php echo he($app_name); ?></title> <link rel="stylesheet" href="stylesheets/estilo.css" type="text/css" /> <link rel="stylesheet" href="stylesheets/screen.css" media="Screen" type="text/css" /> <link rel="stylesheet" href="stylesheets/mobile.css" media="handheld, only screen and (max-width: 480px), only screen and (max-device-width: 480px)" type="text/css" /> <!--[if IEMobile]> <link rel="stylesheet" href="mobile.css" media="screen" type="text/css" /> <![endif]--> <script type="text/javascript" src="/javascript/jquery-1.7.1.min.js"></script> <script type="text/javascript"> function logResponse(response) { if (console && console.log) { console.log('The response was', response); } } $(function(){ // Set up so we handle click on the buttons $('#postToWall').click(function() { FB.ui( { method : 'feed', link : $(this).attr('data-url') }, function (response) { // If response is null the user canceled the dialog if (response != null) { logResponse(response); } } ); }); $('#sendToFriends').click(function() { FB.ui( { method : 'send', link : $(this).attr('data-url') }, function (response) { // If response is null the user canceled the dialog if (response != null) { logResponse(response); } } ); }); $('#sendRequest').click(function() { FB.ui( { method : 'apprequests', message : $(this).attr('data-message') }, function (response) { // If response is null the user canceled the dialog if (response != null) { logResponse(response); } } ); }); }); </script> <!--[if IE]> <script type="text/javascript"> var tags = ['header', 'section']; while(tags.length) document.createElement(tags.pop()); </script> <![endif]--> </head> <body> <div > <div id="titulo2" style="clear:both;"> FANCRACK </div> <div id="texto"> Mas de un millon de canciones registradas </div> </div> <div id="fb-root"></div> <script type="text/javascript"> window.fbAsyncInit = function() { FB.init({ appId : '<?php echo AppInfo::appID(); ?>', // App ID channelUrl : '//<?php echo $_SERVER["HTTP_HOST"]; ?>/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); // Listen to the auth.login which will be called when the user logs in // using the Login button FB.Event.subscribe('auth.login', function(response) { // We want to reload the page now so PHP can read the cookie that the // Javascript SDK sat. But we don't want to use // window.location.reload() because if this is in a canvas there was a // post made to this page and a reload will trigger a message to the // user asking if they want to send data again. window.location = window.location; }); FB.Canvas.setAutoGrow(); }; // Load the SDK Asynchronously (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <header style="border:none" class="clearfix"> <?php if (isset($basic)) { $logoutUrl = $facebook->getLogoutUrl(); ?> <a href="<?php echo $logoutUrl; ?>">Salir</a> <p id="picture" style="background-image:url(https://graph.facebook.com/<?php echo he($user_id);?>/picture?type=normal)"></p> <div> <h1>Bienvenido <strong><?php echo he(idx($basic,'first_name')); ?></strong></h1> <p style="font-size:14px;color:white;" class="tagline"> Aplicacion <a href="<?php echo he(idx($app_info, 'link'));?>" target="_top"><?php echo he($app_name); ?></a> </p> </div> <div style="margin-left:100px;width:500px;height:300px;clear:both;background-color:orange"> djdjjdj </div> <div style="clear:both;width:500px;height:150px;"> <div id="share-app"> <p>Compartir aplicacion:</p> <ul> <li> <a href="#" class="facebook-button" id="postToWall" data-url="<?php echo AppInfo::getUrl(); ?>"> <span class="plus">Escribir en el muro</span> </a> </li> <li> <a href="#" class="facebook-button speech-bubble" id="sendToFriends" data-url="<?php echo AppInfo::getUrl(); ?>"> <span class="speech-bubble">Enviar mensaje</span> </a> </li> <li> <a href="#" class="facebook-button apprequests" id="sendRequest" data-message="Test this awesome app"> <span class="apprequests">Invitar amigos</span> </a> </li> </ul> </div> </div> <?php } else { ?> <div> <div class="fb-login-button" data-scope="user_likes,user_photos"></div> <!-- data scope tien dato importantes --> </div> <div id="subtitulo">Busque las canciones de su artista favorito</div> <div style="margin-left:40px;width:610px;hight:700px;float:left"> <div style="width:300px;height:300px;float:left"> <img src="imagen/discos/ima11.jpg" title="Coldplay"> </div> <div style="width:300px;height:300px;float:left"> <img src="imagen/discos/ima2.jpg" title="The Rolling Stones"> </div> </div> <?php } ?> </header> </body> </html> Estas equivocado esto no es FBML. El FBML eran etiquetas como esta: <fb:name/> que te mostraba el nombre del que entraba en la aplicacion, tu codigo es del dsk de facebook para aplicaciones en iframe. |