Estoy aprendiendo a programar con la API de Twitter y me he bajado la librería PHP de Abraham y el sistema de login mediante mi cuenta de Twitter funciona perfecto.
Ahora lo que quiero hacer es cada usuario que haga login con su cuenta de Twitter se envie un Tweet automático en sus respectivas cuentas.
parece todo correcto, si hay algún error con la api puedes mirar de hacer un print_r a ver que te sale...
$status = $tweet->post('statuses/update', array('status' => 'Prueba'));
print_r($status);
en la web de betabeers también usamos la librería de Abraham :)
1- en primr lugar tienes que tener en cuenta que la app de twitter que estas haciendo requiere permisos de escritura, creo que ahora para activarlo te obligan a poner tu teléfono móvil válido en tu cuenta de twitter, no es visible pero con eso quieren evitar spam.
2- para publicar un tweet a la cuenta del usuario una vez haya dado permisos a tu app, tienes que usar el método de la API - POST statuses/update
https://dev.twitter.com/rest/reference/post/statuses/update
Estoy aprendiendo a programar con la API de Twitter y me he bajado la librería PHP de Abraham y el sistema de login mediante mi cuenta de Twitter funciona perfecto.
Ahora lo que quiero hacer es cada usuario que haga login con su cuenta de Twitter se envie un Tweet automático en sus respectivas cuentas.
¿Me podríais ayudar?
Muchas gracias,
29/12/2014 17:11
$status = $tweet->post('statuses/update', array('status' => 'Prueba'));
print_r($status);
29/12/2014 07:14
en la web de betabeers también usamos la librería de Abraham :)
1- en primr lugar tienes que tener en cuenta que la app de twitter que estas haciendo requiere permisos de escritura, creo que ahora para activarlo te obligan a poner tu teléfono móvil válido en tu cuenta de twitter, no es visible pero con eso quieren evitar spam.
2- para publicar un tweet a la cuenta del usuario una vez haya dado permisos a tu app, tienes que usar el método de la API - POST statuses/update
https://dev.twitter.com/rest/reference/post/statuses/update
suerte!
29/12/2014 14:36
Efectivamente ya tengo la app con permisos de escritura.
Te comento que cada vez que hacen login en mi app guardo en mi base de datos el oauth_token y el oauth_token_secret de la sesion del usuario.
Una vez guardado pruebo esto:
session_start();
require_once('inc/twitteroauth/twitteroauth.php');
include('inc/config.php');
if(!isset($_SESSION['name']) && !isset($_SESSION['twitter_id'])) //check whether user already logged in with twitter
{
redirect('index.php');
}
$datos = $db->QueryFetchArray("SELECT * FROM `usuarios` WHERE `t_id`='".$_SESSION['t_id']."'");
$tweet = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $datos['oauth_token'], $datos['oauth_token_secret']);
$tweet->post('statuses/update', array('status' => 'Prueba'));
29/12/2014 20:48
stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Invalid or expired token [code] => 89 ) ) )
Es como que no guardo el token correcto o algo parecido.
29/12/2014 21:22