コード例 #1
0
ファイル: live.php プロジェクト: btafoya/ohmy-auth
<?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>';
});
コード例 #2
0
ファイル: linkedin.php プロジェクト: btafoya/ohmy-auth
<?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>';
});
コード例 #3
0
ファイル: github.php プロジェクト: btafoya/ohmy-auth
<?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>';
});
コード例 #4
0
ファイル: google.php プロジェクト: btafoya/ohmy-auth
<?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>';
});
コード例 #5
0
ファイル: facebook.php プロジェクト: btafoya/ohmy-auth
<?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>';
});
コード例 #6
0
ファイル: instagram.php プロジェクト: btafoya/ohmy-auth
<?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>';
});