elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  uso de script en php
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: uso de script en php  (Leído 2,636 veces)
mxsoun

Desconectado Desconectado

Mensajes: 43


Ver Perfil
uso de script en php
« en: 20 Mayo 2011, 23:36 pm »

buenas tardes quiero utilizar este script para conectarme a twitter
Código:
<?php
$_pluginInfo=array(
'name'=>'Twitter',
'version'=>'1.1.1',
'description'=>"Get the contacts from a Twitter account",
'base_version'=>'1.8.0',
'type'=>'social',
'check_url'=>'http://twitter.com',
'requirement'=>'user',
'allowed_domains'=>false,
);
/**
 * Twitter Plugin
 *
 * Imports user's contacts from Twitter and
 * posts a new tweet from the user as a invite.
 *
 * @author OpenInviter
 * @version 1.0.3
 */
class twitter extends OpenInviter_Base
{
private $login_ok=false;
public $showContacts=true;
public $requirement='user';
public $internalError=false;
public $allowed_domains=false;
protected $timeout=30;
protected $maxUsers=100;

public $debug_array=array(
'initial_get'=>'username',
'login_post'=>'inbox',
'friends_url'=>'list-tweet',
'wall_message'=>'latest_text',
'send_message'=>'inbox'
);

/**
* Login function
*
* Makes all the necessary requests to authenticate
* the current user to the server.
*
* @param string $user The current user.
* @param string $pass The password for the current user.
* @return bool TRUE if the current user was authenticated successfully, FALSE otherwise.
*/
public function login($user,$pass)
{
$this->resetDebugger();
$this->service='twitter';
$this->service_user=$user;
$this->service_pass=$pass;
if (!$this->init()) return false;
$res=$this->get("https://mobile.twitter.com/session/new",true);
if ($this->checkResponse('initial_get',$res))
$this->updateDebugBuffer('initial_get',"https://mobile.twitter.com/session/new",'GET');
else
{
$this->updateDebugBuffer('initial_get',"https://mobile.twitter.com/session/new",'GET',false);
$this->debugRequest();
$this->stopPlugin();
return false;
}

$form_action="https://mobile.twitter.com/session";
$post_elements=array('authenticity_token'=>$this->getElementString($res,'name="authenticity_token" type="hidden" value="','"'),'username'=>$user,'password'=>$pass);
$res=$this->post($form_action,$post_elements,true);
if ($this->checkResponse('login_post',$res))
$this->updateDebugBuffer('login_post',"{$form_action}",'POST',true,$post_elements);
else
{
$this->updateDebugBuffer('login_post',"{$form_action}",'POST',false,$post_elements);
$this->debugRequest();
$this->stopPlugin();
return false;
}
$this->login_ok="http://mobile.twitter.com/{$user}/followers";
return true;
}

/**
* Get the current user's contacts
*
* Makes all the necesarry requests to import
* the current user's contacts
*
* @return mixed The array if contacts if importing was successful, FALSE otherwise.
*/
public function getMyContacts()
{
if (!$this->login_ok)
{
$this->debugRequest();
$this->stopPlugin();
return false;
}
else $url=$this->login_ok;
$res=$this->get($url);
if ($this->checkResponse('friends_url',$res))
$this->updateDebugBuffer('friends_url',"{$url}",'GET');
else
{
$this->updateDebugBuffer('friends_url',"{$url}",'GET',false);
$this->debugRequest();
$this->stopPlugin();
return false;
}
$contacts=array();$countUsers=0;
do
{
$nextPage=false;
$doc=new DOMDocument();libxml_use_internal_errors(true);if (!empty($res)) $doc->loadHTML($res);libxml_use_internal_errors(false);
$xpath=new DOMXPath($doc);
$query="//a[@name]";$data=$xpath->query($query);
foreach ($data as $node)
{
$user=(string)$node->getAttribute("name");
if (!empty($user)) {$contacts[$countUsers]=$user; $countUsers++; }
}
$query="//div[@class='list-more']/a";$data=$xpath->query($query);
foreach($data as $node) { $nextPage=$node->getAttribute("href");break; }
if ($countUsers>$this->maxUsers) break;
if (!empty($nextPage)) $res=$this->get('http://mobile.twitter.com'.$nextPage);
}
while ($nextPage);
return $contacts;
}

/**
* Send message to contacts
*
* Sends a message to the contacts using
* the service's inernal messaging system
*
* @param string $cookie_file The location of the cookies file for the current session
* @param string $message The message being sent to your contacts
* @param array $contacts An array of the contacts that will receive the message
* @return mixed FALSE on failure.
*/
public function sendMessage($session_id,$message,$contacts)
{
$countMessages=0;$res=$this->get("http://mobile.twitter.com");$auth=$this->getElementString($res,'name="authenticity_token" type="hidden" value="','"');

$form_action="http://mobile.twitter.com";
$post_elements=array("authenticity_token"=>$auth,'tweet[text]'=>$message['body'],'tweet[in_reply_to_status_id]'=>false,'tweet[lat]'=>false,'tweet[long]'=>false,'tweet[place_id]'=>false,'tweet[display_coordinates]'=>false);
$res=$this->post($form_action,$post_elements,true);

foreach($contacts as $screen_name)
{
$countMessages++;$form_action='http://mobile.twitter.com/inbox';
$post_elements=array('authenticity_token'=>$auth,'message[text]'=>$message['body'],'message[recipient_screen_name]'=>$screen_name,'return_to'=>false,);
$res=$this->post($form_action,$post_elements,true);
if ($this->checkResponse('send_message',$res))
$this->updateDebugBuffer('send_message',"{$form_action}",'POST',true,$post_elements);
else
{
$this->updateDebugBuffer('send_message',"{$form_action}",'POST',false,$post_elements);
$this->debugRequest();
$this->stopPlugin();
return false;
}
sleep($this->messageDelay);
if ($countMessages>$this->maxMessages) {$this->debugRequest();$this->resetDebugger();$this->stopPlugin();break;}
}
}

/**
* Terminate session
*
* Terminates the current user's session,
* debugs the request and reset's the internal
* debudder.
*
* @return bool TRUE if the session was terminated successfully, FALSE otherwise.
*
*/
public function logout()
{
if (!$this->checkSession()) return false;
$this->get("http://twitter.com/logout");
$this->debugRequest();
$this->resetDebugger();
$this->stopPlugin();
return true;
}
}

?>

quiero llamar el code en x.php desde aqui quiero enviar mi user y password para que lo valide y si es incorrecto me mande el error y si se ingreso me diga que mi login fue correcto, no se usar esta clase y no se si todo el codigo me sirva solo quiero hacer el login. como lo tendria que usar?


En línea

Feedeex

Desconectado Desconectado

Mensajes: 173


Ver Perfil
Re: uso de script en php
« Respuesta #1 en: 21 Mayo 2011, 00:00 am »

¿Sabés programar?


En línea

tragantras


Desconectado Desconectado

Mensajes: 465


Ver Perfil
Re: uso de script en php
« Respuesta #2 en: 21 Mayo 2011, 16:03 pm »

¿Sabés programar?


best reply ever possible! xD

yo diría que no sabe no... aprende PHP mejor primero...


PD: instancia la clase, pero es una clase hija, como no tengas OpenInviter_Base malamente!
En línea

Colaboraciones:
1 2
Nakp
casi es
Ex-Staff
*
Desconectado Desconectado

Mensajes: 6.336

he vuelto :)


Ver Perfil WWW
Re: uso de script en php
« Respuesta #3 en: 21 Mayo 2011, 18:08 pm »

seguro que no tienes ni esta clase entre tus archivos: OpenInviter_Base
En línea

Ojo por ojo, y el mundo acabará ciego.
mxsoun

Desconectado Desconectado

Mensajes: 43


Ver Perfil
Re: uso de script en php
« Respuesta #4 en: 23 Mayo 2011, 00:02 am »

se programar no mucho, pero me fallan las clases y solo quiero trabajar con esta clase y no con todo el paquete de openinviter, pero no se como manipular solo este archivo.
e intentado realizar la conexion por curl pero prefiero saber que se podria hacer con esta clase
En línea

tragantras


Desconectado Desconectado

Mensajes: 465


Ver Perfil
Re: uso de script en php
« Respuesta #5 en: 23 Mayo 2011, 18:41 pm »

sabes algo de clases y de herencia?

esa clase depende de la clase padre!
En línea

Colaboraciones:
1 2
WHK
Moderador Global
***
Desconectado Desconectado

Mensajes: 6.589


Sin conocimiento no hay espíritu


Ver Perfil WWW
Re: uso de script en php
« Respuesta #6 en: 23 Mayo 2011, 19:20 pm »

es como si quisieras usar el photoshop con una sola dll sin ejecutables ni nada mas, no se puede, esa clase es una EXTENSION de otra clase que a su ves debe usar mas clases, en otras palabras eberás utilizar todo el paquete a menos que lo programes tu de cero o encuentres otra alternativa.

Mañana mismo le saco el asiento al vehiculo y con eso me voy al trabajo y dejo todo el resto del carro en la cochera porque no me sirve.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[shell script] ayuda con script, :( « 1 2 »
Scripting
dark_fidodido 14 10,800 Último mensaje 16 Septiembre 2009, 10:28 am
por dark_fidodido
script bash (ubuntu): Parar un proceso sin salir del script (SOLUCIONADO)
Scripting
moikano→@ 6 11,065 Último mensaje 28 Octubre 2010, 15:48 pm
por moikano→@
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines