Example #1
0
 public function testRequestToken()
 {
     $phpunit = $this;
     Auth1::init(3)->set('key', getenv('FITBIT_KEY'))->set('secret', getenv('FITBIT_SECRET'))->set('callback', getenv('CALLBACK'))->request('http://api.fitbit.com/oauth/request_token')->finally(function ($data) use($phpunit) {
         $phpunit->assertTrue(!empty($data['oauth_token']));
         $phpunit->assertTrue(!empty($data['oauth_token_secret']));
     });
 }
Example #2
0
 public function testLegsThreeLegged()
 {
     $phpunit = $this;
     Auth1::legs(3)->then(function ($data) use($phpunit) {
         $phpunit->assertArrayHasKey('oauth_callback', $data);
         $phpunit->assertArrayHasKey('oauth_consumer_key', $data);
         $phpunit->assertArrayHasKey('oauth_consumer_secret', $data);
         $phpunit->assertArrayHasKey('oauth_nonce', $data);
         $phpunit->assertArrayHasKey('oauth_signature_method', $data);
         $phpunit->assertArrayHasKey('oauth_timestamp', $data);
         $phpunit->assertArrayHasKey('oauth_token', $data);
         $phpunit->assertArrayHasKey('oauth_verifier', $data);
         $phpunit->assertArrayHasKey('oauth_version', $data);
     });
 }
Example #3
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
/*
 * Copyright (c) 2014, Yahoo! Inc. All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */
use ohmy\Auth1;
# initialize 3-legged oauth
$fitbit = Auth1::legs(3)->set('key', 'your consumer key')->set('secret', 'your consumer secret')->set('callback', 'your callback url')->request('http://api.fitbit.com/oauth/request_token')->authorize('http://www.fitbit.com/oauth/authorize')->access('http://api.fitbit.com/oauth/access_token')->finally(function ($data) use(&$user_id) {
    $user_id = $data['encoded_user_id'];
});
# test GET call
$fitbit->GET("https://api.fitbit.com/1/user/{$user_id}/profile.json")->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});
Example #4
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
/*
 * Copyright (c) 2014, Yahoo! Inc. All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */
use ohmy\Auth1;
# initialize 3-legged oauth
$yahoo = Auth1::legs(3)->set(array('key' => 'your consumer key', 'secret' => 'your consumer secret', 'callback' => 'your callback'))->request('https://api.login.yahoo.com/oauth/v2/get_request_token')->authorize('https://api.login.yahoo.com/oauth/v2/request_auth')->access('https://api.login.yahoo.com/oauth/v2/get_token');
$yahoo->GET('https://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.contacts%20where%20guid%3Dme%3B&format=json&diagnostics=true&callback=')->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});
Example #5
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
/*
 * Copyright (c) 2014, Yahoo! Inc. All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */
use ohmy\Auth1;
# initialize 2-legged oauth
$termie = Auth1::legs(2)->set('oauth_consumer_key', 'key')->set('oauth_consumer_secret', 'secret')->request('http://term.ie/oauth/example/request_token.php')->access('http://term.ie/oauth/example/access_token.php')->finally(function ($data) use(&$token, &$secret) {
    $token = $data['oauth_token'];
    $secret = $data['oauth_token_secret'];
});
# test GET call
$termie->GET('http://term.ie/oauth/example/echo_api.php?method=get')->then(function ($response) {
    var_dump($response->text());
});
# test POST call
$termie->POST('http://term.ie/oauth/example/echo_api.php', array('method' => 'post'))->then(function ($response) {
    var_dump($response->text());
});
# test revival
$termie2 = Auth1::init(2)->set('oauth_consumer_key', 'key')->set('oauth_consumer_secret', 'secret')->access($token, $secret)->GET('http://term.ie/oauth/example/echo_api.php?method=revive')->then(function ($response) {
    var_dump($response->text());
});
Example #6
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
/*
 * Copyright (c) 2014, Yahoo! Inc. All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */
use ohmy\Auth1;
# initialize 3-legged oauth
$twitter = Auth1::legs(3)->set(array('key' => 'your consumer key', 'secret' => 'your consumer secret', 'callback' => 'your callback url'))->request('https://api.twitter.com/oauth/request_token')->authorize('https://api.twitter.com/oauth/authorize')->access('https://api.twitter.com/oauth/access_token');
# test GET call
$twitter->GET('https://api.twitter.com/1.1/statuses/home_timeline.json', array('count' => 5))->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});
Example #7
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
/*
 * Copyright (c) 2014, Yahoo! Inc. All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */
use ohmy\Auth1;
# initialize 3-legged oauth
$tumblr = Auth1::legs(3)->set('key', 'your consumer key')->set('secret', 'your consumer secret')->set('callback', 'your callback url')->request('http://www.tumblr.com/oauth/request_token')->authorize('http://www.tumblr.com/oauth/authorize')->access('http://www.tumblr.com/oauth/access_token');
# test GET method
$tumblr->GET('https://api.tumblr.com/v2/user/info')->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});