PHP code example of saturn / twarpy

1. Go to this page and download the library: Download saturn/twarpy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

saturn / twarpy example snippets


use Twarpy\Twarpy;

$config = array(
  "consumer_key"    => "YOURCONSUMERKEY",
  "consumer_secret" => "YOURCONSUMERSECRET"
);
$Twarpy = new Twarpy($config, THREE_LEGGED);
// Save the oauth token and oauth token secret The next time you
// run Twarpy for that user you can 

$config = array(
  "consumer_key"    => "YOURCONSUMERKEY",
  "consumer_secret" => "YOURCONSUMERSECRET",
  "access_token"    => "YOURACCESSTOKEN",
  "token_secret"    => "YOURSECRETTOKEN"
);
$Twarpy = new Twarpy($config, THREE_LEGGED);

$config = array(
  "consumer_key"    => "YOURCONSUMERKEY",
  "consumer_secret" => "YOURCONSUMERSECRET"
);
$Twarpy = new Twarpy($config, APP_ONLY);

$tokens = $Twarpy->getAccessToken();
// returns array("access_token" => ???)

$config = array(
  "consumer_key"    => "YOURCONSUMERKEY",
  "consumer_secret" => "YOURCONSUMERSECRET",
  "access_token"    => "YOURACCESSTOKEN"
);
$Twarpy = new Twarpy($config, APP_ONLY);

$params = array("screen_name" => "twitter");
$data = $Twarpy->request('statuses/user_timeline', 'GET', $params);

use Twarpy\Twarpy;
    'consumer_key'      => "YOURCONSUMERKEY",
    'consumer_secret'   => "YOURCONSUMERSECRET",
    'access_token'      => 'YOURACCESSTOKEN',
    'token_secret'      => 'YOURSECRETTOKEN'
);

try {
    $twarpy = new Twarpy($config, THREE_LEGGED);
    $tweet  = array("status" => "Testing Twarpy! #Twarpy");
    $data   = $twarpy->request('statuses/update', 'POST', $tweet);
    print_r($data);
} catch (Exception $e) {
    print_r($e->getMessage());
}