okuya****@workg*****
okuya****@workg*****
2011年 5月 17日 (火) 13:36:34 JST
おく@Workgroupです。
MLに張り付けても問題なさげな部分だけ・・
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Gree_Platform
{
protected $CI = null;
protected $_is_authorize = false;
public function __construct()
{
$this->CI =& get_instance();
// application/libraries配下に置いてます
require_once APPPATH . 'libraries/OAuth/OAuth.php';
// application/pear に置いて、
// hook で、ini_set('include_path',APPPATH.'pear/'.PATH_SEPARATOR.ini_get('include_path'))
してます。
require_once 'HTTP/Request2.php';
// 設定まわりはapplication/config に置いて、切り替えてもらいましょう
$check_locations = defined('ENVIRONMENT')
? array(ENVIRONMENT.'/oauth.ini', 'oauth.ini')
: array('oauth.ini');
foreach ($check_locations as $location)
{
$file_path = APPPATH.'config/'.$location;
if (file_exists($file_path))
{
break;
}
}
$this->app_conf = parse_ini_file($file_path, true);
$this->oauth_conf = $this->app_conf['oauth'];
// アプリコースの設定も追加したので・・・
$this->app_conf = $this->app_conf['app'];
log_message('debug', "Gree_Platform Class Initialized");
}
public function authorize()
{
log_message('debug', "Gree_Platform::authorize");
if(isset($_SERVER['HTTP_AUTHORIZATION']))
{
log_message('debug', $_SERVER['HTTP_AUTHORIZATION']);
// parse user request
$user_request = OAuthRequest::from_request(null, null, null);
$oauth_token = $user_request->get_parameter('oauth_token');
$oauth_token_secret = $user_request->get_parameter('oauth_token_secret');
$oauth_signature = $user_request->get_parameter('oauth_signature');
// verify gadget server request
$signature_method = new OAuthSignatureMethod_HMAC_SHA1();
$oauth_consumer = new OAuthConsumer($this->oauth_conf['consumer_key'],
$this->oauth_conf['consumer_secret']);
$access_token = new OAuthToken($oauth_token, $oauth_token_secret);
$signature_valid =
$signature_method->check_signature($user_request, $oauth_consumer,
$access_token, $oauth_signature);
if ($signature_valid !== true) {
header('HTTP/1.1 403 Forbidden');
return false;
} else {
// 検証OK
$this->_is_authorize = true;
return true;
}
} else {
// OAuthヘッダがない
header('HTTP/1.1 403 Forbidden');
return false;
}
}
他キャリアの課金周りのライブラリと共通にした経緯から、
こんな感じです。
2011年5月17日13:17 HAMAGUCHI Seiji <makot****@dive-*****>:
> ドトールのコーヒーってやっぱりおいしいですね。
> 濱口@スマイルロジックです。
>
> 冷静に自分のソースを読んでいたら、typoを発見しました。
> でも、まだエラーが・・・。
>
> A PHP Error was encountered
> Severity: 8192
> Message: Assigning the return value of new by reference is deprecated
> Filename: HTTP/Request.php
> Line Number: 402
>
> んーEnglishページでは、エラーを抑制すれば良いんじゃね。的な事が書かれていますが、
> もう少し探求してみます。自分の欲しい結果に到達していませんし。
>
> 人間、熱くなるとダメだな。
>
> --
> Makoto / HAMAGUCHI Seiji
> makot****@dive-*****
> http://smilelogic.jp/makoto/
> http://twitter.com/mako10z/
> <!-
> 個人事業主: スマイルロジック(smileLogic)
> mail: hamag****@smile*****
> web: http://smilelogic.jp/
> titter : http://twitter.com/smilelogic_jp/
> -!>
>
> _______________________________________________
> Codeigniter-users mailing list
> Codei****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>