Я действительно борюсь с OAuth для Академии Хана. Это для веб-сайта моего класса (я учитель), и я хочу получить пользовательские данные о конкретных учениках. Если бы я мог сделать 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();
}
?>