Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/01/2010, 18:32
Avatar de danistrein
danistrein
 
Fecha de Ingreso: septiembre-2008
Ubicación: Salta Capital
Mensajes: 550
Antigüedad: 15 años, 7 meses
Puntos: 9
Exclamación recibiendo datos en php

hola compañeros php, quiero hacerles una pregunta sobre un code que me pasaron para una aplicación de facebook. miren:


index.php:
Código PHP:
Ver original
  1. <?
  2. $urlApli = 'http://apps.facebook.com/clicktops/';
  3. $clicktopssegundos = 10 ;
  4. ?>
Código Javascript:
Ver original
  1. <script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/es_LA" type="text/javascript"></script>
  2. <script type="text/javascript">
  3. var vclick=0,vtime=10,start=1,interval,temp=0;
  4. function mclick(){
  5.     vclick += 1;
  6.     document.getElementById('eclick').setTextValue(vclick);
  7.     document.getElementById('eon').setValue(vclick);
  8.     if(start == 1){interval = setInterval(function(){
  9.         if((vclick-temp)>100)
  10.             vclick=temp;
  11.         temp=vclick;
  12.         vtime -= 1;
  13.         document.getElementById('etime').setTextValue(vtime);
  14.         if (vtime <= 0)end();
  15.     },1000);start = 0;}
  16. }
  17.  
  18. function end(){
  19.     if((vclick-temp)>100)
  20.         vclick=temp;
  21.     clearInterval(interval);
  22.     document.getElementById('eon').setDisabled(true);
  23.     document.getElementById('reintentar').setStyle('display',"block");
  24.     document.getElementById('publicidad').setStyle('display',"none");
  25.     publicar();
  26.     subirClicks();
  27. }
  28. function reintentar(){
  29.     vclick=0;
  30.     vtime=10;
  31.     start=1;
  32.     temp=0;
  33.     interval=null;
  34.     document.getElementById('reintentar').setStyle('display',"none");
  35.     document.getElementById('publicidad').setStyle('display',"block");
  36.     document.getElementById('eon').setValue('Comenzar');
  37.     document.getElementById('eclick').setTextValue('0');
  38.     document.getElementById('etime').setTextValue('10');
  39.     document.getElementById('eon').setDisabled(false);
  40. }
  41. function subirClicks()  {
  42.         ajax = new Ajax();
  43.         ajax.responseType = Ajax.JSON;
  44.         ajax.requireLogin = true;              
  45.         ajax.post('guardar.php',{"core":vclick});          
  46. }
  47. function publicar(){
  48.     var user_message_prompt = "¿Que estas pensando sobre ClickTops?";
  49.     var user_message = 'Pude hacer '+vclick+' clicks en <?=$clicktopssegundos?> segundos! Vos cuanto haces?';
  50.     var attachment = {
  51.     'name':'Pude hacer '+vclick+' clicks en <?=$clicktopssegundos?> segundos! Vos cuanto haces?',
  52.     'href':'<?=$urlApli?>',
  53.     'caption':'Eres mas rapido? Demuestralo! Trata de entrar en los tops!',
  54.     'media':[{'type':'image','src':'http://photos-g.ak.fbcdn.net/photos-ak-sf2p/v43/194/238715744846/app_1_238715744846_3719.gif','href':'<?=$urlApli?>'}
  55.     ]};
  56.  
  57.     Facebook.streamPublish(user_message,attachment,'','',user_message_prompt); 
  58. }
  59. function mostrarChat(){
  60. document.getElementById('chat').setStyle('display',"block");
  61. document.getElementById('mostrarChat').setStyle('display',"none");
  62. document.getElementById('ocultarChat').setStyle('display',"block");
  63. }
  64. function ocultarChat(){
  65. document.getElementById('chat').setStyle('display',"none");
  66. document.getElementById('mostrarChat').setStyle('display',"block");
  67. document.getElementById('ocultarChat').setStyle('display',"none");
  68. }
  69. </script>


guardar.php
Código PHP:
Ver original
  1. <?php
  2. if(!$_POST)
  3.     exit;
  4.  
  5. require_once 'facebook.php';
  6. $appapikey = 'codigoapi';
  7. $appsecret = 'codigosecret';
  8. $facebook = new Facebook($appapikey, $appsecret);
  9. $user_id = $facebook->require_login();
  10.  
  11.  
  12. $puntos=$_POST['core'];
  13. if(!is_numeric($puntos))
  14.     exit;
  15. $puntos=intval($puntos);
  16. $puntos=$puntos>4000?-100000000000000000000000000000000000000000000:$puntos;
  17.  
  18. $bd_servidor = "localhost";
  19. $bd_usuario = "";
  20. $bd_contrasenya = "";
  21. $bd_bdname = "";
  22. $con=mysql_connect($bd_servidor,$bd_usuario,$bd_contrasenya);
  23. $bd_conect=mysql_select_db($bd_bdname,$con);
  24.  
  25.  
  26. $datos=array($user,$puntos);
  27. $campos=array('userid','puntos');
  28.  
  29. $sql="SELECT * FROM ranking WHERE userid=".intval($user);
  30. $query=mysql_query($sql);
  31. if(mysql_num_rows($query)>0){
  32.     $sSQL="UPDATE ranking SET puntos=".intval($puntos)." WHERE userid=".intval($user);
  33.     $queryr=mysql_query($sSQL);
  34. }else{
  35.     $sSQL=sprintf("INSERT INTO %s (%s) VALUES (%s)","ranking",implode(',',$campos),'\''.implode("','",$datos).'\'');
  36.     $queryr=mysql_query($sSQL);
  37. }
  38.  
  39.  
  40. ?>
  41. {"ok":true}

bueno quisiera saber si podrían decirme si tiene algún error, y como solucionarlo, por asi como esta no me funciona :S

muchas gracias desde ya. espero lo antes posible una solucion. saludos.
__________________
Appones.net - www.appones.net