PHP code example of duncan3dc / oauth

1. Go to this page and download the library: Download duncan3dc/oauth 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/ */

    

duncan3dc / oauth example snippets


use duncan3dc\OAuth\Twitter;
use duncan3dc\SqlClass\Sql;

Sql::addServer("twitter", [
    "hostname"  =>  "example.com",
    "username"  =>  "my_twitter_app",
    "password"  =>  "secret_password",
    "database"  =>  "twitter",
]);

$twitter = new Twitter([
    "username"  =>  "my_handle",
    "authkey"   =>  "XfHrRTY25FgkyqxDfbpe",
    "secret"    =>  "gwj8c29GHDWdphmQhGtHPx4GybwRfhXplT3CD0VG1n",
]);

# The authorise method returns null if we are already authorised. Otherwise it returns a url to grant at
if ($url = $twitter->authorise()) {
    throw new \Exception("Authorsation failed, grant permission here: " . $url);
}

$userData = $twitter->user("my_handle");
print_($userData);

use duncan3dc\OAuth\Twitter;
use MrCoder\MyCustom\Sql;

\duncan3dc\OAuth\Sql::useClass(Sql::class);

$twitter = new Twitter([

use duncan3dc\OAuth\Twitter;
use duncan3dc\SqlClass\Sql;

Sql::addServer("twitter", [
    "hostname"      =>  "example.com",
    "username"      =>  "my_twitter_app",
    "password"      =>  "secret_password",
    "database"      =>  "twitter",
    "definitions"   =>  ["oauth" => "my_other_database"],
]);

$twitter = new Twitter([