Advertisement
irokemr

Twitear mensaje en php api twitter

Jul 18th, 2020
1,893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. require 'TwitterAPIExchange.php';
  4.  
  5. // array de acceso
  6. $settings = array(
  7.     'oauth_access_token' => 'mi-token-acceso',
  8.     'oauth_access_token_secret' => 'mi-token-acceso-secreto',
  9.     'consumer_key' => 'mi-api-key',
  10.     'consumer_secret' => 'mi-api-key-secreta',
  11. );
  12.  
  13. // url
  14. $url = "https://api.twitter.com/1.1/statuses/update.json";
  15.  
  16. // tipo de metodo
  17. $requestMethod = 'POST';
  18.  
  19. //tweet
  20. $postfields = array('status' => 'Mi tweet enviado desde PHP');
  21.  
  22. // instancia de la conexion con twitter
  23. $twitter = new TwitterAPIExchange ($settings);
  24.  
  25. // enviamos el tweet
  26. $response = $twitter->buildOauth($url, $requestMethod)
  27.                     ->setPostfields($postfields)
  28.                     ->performRequest();
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement