Esempio n. 1
0
 public function testInitThreeLegged()
 {
     $phpunit = $this;
     Auth2::init(3)->then(function ($data) use($phpunit) {
         $phpunit->assertArrayHasKey('client_id', $data);
         $phpunit->assertArrayHasKey('client_secret', $data);
         $phpunit->assertArrayHasKey('redirect_uri', $data);
         $phpunit->assertArrayHasKey('code', $data);
         $phpunit->assertArrayHasKey('scope', $data);
         $phpunit->assertArrayHasKey('state', $data);
     });
 }
Esempio n. 2
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\Auth2;
# initialize 3-legged oauth
$instagram = Auth2::legs(3)->set('id', 'your client id')->set('secret', 'your client secret')->set('redirect', 'your redirect uri')->set('scope', 'wl.basic')->authorize('https://login.live.com/oauth20_authorize.srf')->access('https://login.live.com/oauth20_token.srf')->finally(function ($data) use(&$access_token) {
    $access_token = $data['access_token'];
});
# test GET call
$instagram->GET("https://apis.live.net/v5.0/me?access_token={$access_token}")->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});
Esempio n. 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\Auth2;
# initialize 3-legged oauth
$linkedin = Auth2::legs(3)->set('id', 'your client id')->set('secret', 'your client secret')->set('redirect', 'your redirect uri')->authorize('https://www.linkedin.com/uas/oauth2/authorization')->access('https://www.linkedin.com/uas/oauth2/accessToken')->finally(function ($data) use(&$access_token) {
    $access_token = $data['access_token'];
});
# test GET call
$linkedin->GET("https://api.linkedin.com/v1/people/~?oauth2_access_token={$access_token}")->then(function ($response) {
    echo '<pre>';
    var_dump($response->text);
    echo '</pre>';
});
Esempio n. 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\Auth2;
# configuration
$github = Auth2::legs(3)->set('id', 'your client id')->set('secret', 'your client secret')->set('redirect', 'your redirect uri')->authorize('https://github.com/login/oauth/authorize')->access('https://github.com/login/oauth/access_token')->finally(function ($data) use(&$access_token) {
    $access_token = $data['access_token'];
});
# access github api
$github->GET("https://api.github.com/user?access_token={$access_token}", null, array('User-Agent' => 'ohmy-auth'))->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});
Esempio n. 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\Auth2;
# initialize 3-legged oauth
$google = Auth2::legs(3)->set('id', 'your client id')->set('secret', 'your client secret')->set('redirect', 'your redirect uri')->set('scope', 'profile')->authorize('https://accounts.google.com/o/oauth2/auth')->access('https://accounts.google.com/o/oauth2/token')->finally(function ($data) use(&$access_token) {
    $access_token = $data['access_token'];
});
# test GET call
$google->GET("https://www.googleapis.com/plus/v1/people/me?access_token={$access_token}")->then(function ($response) {
    echo '<pre>';
    var_dump($response->text);
    echo '</pre>';
});
Esempio n. 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\Auth2;
# initialize 3-legged oauth
$facebook = Auth2::legs(3)->set(array('id' => 'your client id', 'secret' => 'your client secret', 'redirect' => 'your redirect uri', 'scope' => 'read_stream'))->authorize('https://www.facebook.com/dialog/oauth')->access('https://graph.facebook.com/oauth/access_token')->finally(function ($data) use(&$access_token) {
    $access_token = $data['access_token'];
});
# test GET call
$facebook->GET("https://graph.facebook.com/me/home?access_token={$access_token}")->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});
Esempio n. 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\Auth2;
# initialize 3-legged oauth
$instagram = Auth2::legs(3)->set('id', 'your client id')->set('secret', 'your client secret')->set('redirect', 'your redirect uri')->set('scope', 'basic')->authorize('https://api.instagram.com/oauth/authorize')->access('https://api.instagram.com/oauth/access_token')->finally(function ($data) use(&$access_token) {
    $access_token = $data['access_token'];
});
# test GET call
$instagram->GET("https://api.instagram.com/v1/users/self/feed/?access_token={$access_token}")->then(function ($response) {
    echo '<pre>';
    var_dump($response->json());
    echo '</pre>';
});