0

カーン アカデミーの OAuth に本当に苦労しています。これは私のクラスの Web サイト (私は教師です) 用で、特定の生徒のユーザー データを取得したいと考えています。OAUTH を実行できれば問題ありません。PHPを使用しています。
そこには多くのライブラリがあるようです。私はGoogle Oauthで遊んでいます(ここにありますhttp://code.google.com/p/oauth-php/source/browse/trunk/example/client/twolegged.php

トークン リクエストをうまく作成できますが、スクリプトで呼び出すと、別のページにリダイレクトしようとしてそこでブロックされるようです。
http://myonlinegrades.com/prealg/khan/oauth-php/example/client/twoleggedtest.php

私は本当に苦労しています - 私はあなたが提供するかもしれないどんな助けも大好きです.

以下のコード:

<?php

include_once "../../library/OAuthStore.php";
include_once "../../library/OAuthRequester.php";

// Test of the OAuthStore2Leg 
// uses http://term.ie/oauth/example/

$key = '*********';//'<your app's API key>';
$secret = '***********';//'<your app's secret>';
$callBack = "http://myonlinegrades.com/prealg/test2.php5";
$url = 'http://www.khanacademy.org/api/auth/request_token';

$options = array('consumer_key' => $key, 'consumer_secret' => $secret);
OAuthStore::instance("2Leg", $options);

$method = "GET";
//$params = null;
$params = array(oauth_consumer_key => $key,oauth_callback=>$callBack);
try
{
    // Obtain a request object for the request we want to make
    $request = new OAuthRequester($url, $method, $params);

    // Sign the request, perform a curl request and return the results, 
    // throws OAuthException2 exception on an error
    // $result is an array of the form: array ('code'=>int, 'headers'=>array(), 'body'=>string)
    $result = $request->doRequest();

    $response = $result['body'];

    if ($response != 'oauth_token=requestkey&oauth_token_secret=requestsecret') 
    {
        echo 'Error! $response ' . $response;
    }
    else 
    {
    }


    var_dump($response);
}
catch(OAuthException2 $e)
{
    echo "Exception" . $e->getMessage();
}

?>
4

1 に答える 1

2

これがあなたが探しているものかどうかはわかりませんが、Temboo SDK を使用して Khan Academy で oAuth を実行する簡単な例をまとめました: https://github.com/matthewflaming/temboo-experiments/tree/masterをご覧ください。 /KhanAcademyOauth

(完全な開示: 私は Temboo で働いています)

于 2013-02-13T23:16:18.160 に答える