1

Error al tratar de realizar retweet usando TwitterAPIExchange.php Trato de ocupar este código:

<?php
 ini_set('display_errors', 1);
 require_once('TwitterAPIExchange.php');


function RT($id){   
    $settings = array(
    'oauth_access_token' => 'xxxxxxx',
    'oauth_access_token_secret' => 'xxxxxx',
    'consumer_key' => 'xxxxxx',
    'consumer_secret' => 'xxxxxxxx',
     );

     $url = 'https://api.twitter.com/1.1/statuses/retweet/'.$id.'.json';
     $requestMethod = 'POST';
     $twitter = new TwitterAPIExchange($settings);
     return $twitter->buildOauth($url, $requestMethod)->performRequest();
}

echo RT("901856631855730689");
?>

Este error aparece al momento de ejecutar el código

{"errors":[{"code":32,"message":"Could not authenticate you."}]}

Alguna idea de cual es el motivo.

1 respuesta 1

0

Luego de un poco de investigación logre encontrar la respuesta:

 $url = 'https://api.twitter.com/1.1/statuses/retweet/'.$id_tweet.'.json';
 $postfields=array();
 $requestMethod = 'POST';
 $wp = array(CURLOPT_SSL_VERIFYPEER => false);
 $twitter = new TwitterAPIExchange($settings);
 $string = json_decode($twitter->setPostfields($postfields)
        ->buildOauth($url, $requestMethod)
        ->performRequest(true,$wp),$assoc = TRUE); 
 return($string['text']);

Solo es cuestion de agregarle el

setPostfields($postfields)

antes de

buildOauth

Espero le funcione como referencia Gracias

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.