Repositorio para la herramienta Tupale completo https://tupale.co
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
4.5KB

  1. <?php
  2. session_start();
  3. ini_set('display_errors', 'On');
  4. require ('milfs/xajax/xajax.inc.php');
  5. $xajax = new xajax("");
  6. require ("milfs/funciones/conex.php");
  7. require ('milfs/funciones/funciones.php');
  8. require ("milfs/includes/parametrizacion.php");
  9. //$login_uid ="547312246";
  10. if($_REQUEST['provider'] !="") {
  11. $login_servicio ="$_REQUEST[provider]";
  12. }
  13. else {
  14. $login_servicio ="twitter";
  15. }
  16. /*
  17. $nombres ="nombres apellidos";
  18. $usuario ="displayName";
  19. $email ="email@email";
  20. $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
  21. $info = json_encode($arr);
  22. */
  23. $xajax->processRequests();
  24. /*
  25. $existe = social_login("consultar","$login_servicio","$login_uid");
  26. if($existe =="") {
  27. $control = md5(rand(1,99999999).microtime());
  28. $password = md5(rand(1,99999999).microtime());
  29. $insertar_uid = insertar_linea("form_datos","$login_formulario","$social_login_uid","$login_uid",$control,"","");
  30. $insertar_servicio = insertar_linea("form_datos","$login_formulario","$social_login_servicio","$login_servicio",$control,"","");
  31. $insertar_nombres = insertar_linea("form_datos","$login_formulario","$login_campo_nombres","$nombres",$control,"","");
  32. $insertar_password = insertar_linea("form_datos","$login_formulario","$login_campo_password","$password",$control,"","");
  33. $insertar_usuario = insertar_linea("form_datos","$login_formulario","$login_campo_usuario","$usuario",$control,"","");
  34. $insertar_email = insertar_linea("form_datos","$login_formulario","$login_campo_email","$email",$control,"","");
  35. $insertar_info = insertar_linea("form_datos","$login_formulario","$login_campo_info","$info",$control,"","");
  36. }
  37. else {$resultado ="$existe";}
  38. */
  39. require_once( "./milfs/librerias/hybridauth/Hybrid/Auth.php" );
  40. require_once( "./milfs/librerias/hybridauth/Hybrid/Endpoint.php" );
  41. $config = './milfs/librerias/hybridauth/config.php';
  42. if (isset($_REQUEST['hauth_start']))
  43. {
  44. Hybrid_Endpoint::process();
  45. }
  46. try{
  47. $hybridauth = new Hybrid_Auth( $config );
  48. $twitter = $hybridauth->authenticate( "$login_servicio" );
  49. $user_profile = $twitter->getUserProfile();
  50. $login_uid = $user_profile->identifier;
  51. if($login_uid !="" ) {
  52. $existe = social_login("consultar","$login_servicio","$login_uid");
  53. if($existe =="") {
  54. $nombre = $user_profile->firstName;
  55. $apellido = $user_profile->lastName;
  56. $nombres ="$nombre $apellido";
  57. $usuario =$user_profile->displayName;
  58. $email =$user_profile->email;
  59. $avatar =$user_profile->photoURL;
  60. $info = json_encode($user_profile);
  61. $control = md5(rand(1,99999999).microtime());
  62. $password = md5(rand(1,99999999).microtime());
  63. $insertar_uid = insertar_linea("form_datos","$login_formulario","$social_login_uid","$login_uid",$control,"","");
  64. $insertar_servicio = insertar_linea("form_datos","$login_formulario","$social_login_servicio","$login_servicio",$control,"","");
  65. $insertar_nombres = insertar_linea("form_datos","$login_formulario","$login_campo_nombres","$nombres",$control,"","");
  66. $insertar_password = insertar_linea("form_datos","$login_formulario","$login_campo_password","$password",$control,"","");
  67. $insertar_usuario = insertar_linea("form_datos","$login_formulario","$login_campo_usuario","$usuario",$control,"","");
  68. $insertar_email = insertar_linea("form_datos","$login_formulario","$login_campo_email","$email",$control,"","");
  69. $insertar_avatar = insertar_linea("form_datos","$login_formulario","$login_campo_avatar","$avatar",$control,"","");
  70. $insertar_info = insertar_linea("form_datos","$login_formulario","$login_campo_info","$info",$control,"","");
  71. $login = social_login("login","$login_servicio","$login_uid");
  72. }
  73. else {
  74. $login = social_login("login","$login_servicio","$login_uid");
  75. }
  76. }
  77. $resultado = "Hola! " . $user_profile->displayName." // ". $user_profile->identifier;
  78. // $twitter->setUserStatus( "Estoy en http://tupale.co donde toda causa se gana! " );
  79. // $user_contacts = $twitter->getUserContacts();
  80. }
  81. catch( Exception $e ){
  82. $resultado = "Ooophs, we got an error: " . $e->getMessage();
  83. }
  84. echo $resultado;