OAuth for Googleで少し問題が発生しました。CodeIgniter(http://codeigniter.com/wiki/OAuth_for_Google)にJim Saunder Libraireを使用していますが、access_youtube関数にアクセスすると次のようになります。
public function access_youtube()
{ //STEP 2
// Here is the first call to load the library
$params['key'] = 's390075769.onlinehome.fr';
$params['secret'] = 'iHD72YKzWmbm8VTwncht_E-d';
// We can change the signing algorithm and http method by setting the following in your params array.
$params['algorithm'] = 'HMAC-SHA1';
// $params['method'] = "GET";
// We need to reload the library since we left our site beetween Step 1 & 2.
$this->load->library('google_oauth', $params);
// We are using HMAC signing you need to specify the token_secret you got from the request step as the second parameter of this method. So
$token_secret = $this->session->userdata('token_secret');
$oauth = $this->google_oauth->get_access_token(false, $token_secret);
// The access method will return an array with keys of ‘oauth_token’, and ‘oauth_token_secret’
// These values are your access token and your access token secret. We should store these in our database.
$this->session->set_userdata('oauth_token', $oauth['oauth_token']);
$this->session->set_userdata('oauth_token_secret', $oauth['oauth_token_secret']);
// Now you have an access token and can make google service requests on your users behalf
redirect(site_url());
}
いくつかのエラーメッセージが表示されました:
未定義のインデックス:oauth_token
未定義のインデックス:oauth_token_secret
$ this-> session->set_userdata..の行を参照します。
そして、各エラーメッセージの後に私は得る:
メッセージ:ヘッダー情報を変更できません-ヘッダーは既に送信されています(出力は/homepages/7/d390075755/htdocs/system/core/Exceptions.php:170で開始されました)ファイル名:libraries / Session.php行番号:671
これは、前のエラーメッセージに関連していると思います。
だから私はコンストラクターでそれを試しました:
class Example extends CI_Controller
{
private $CI;
public function __construct()
{
parent::__construct();
$this->CI =& get_instance();
$this->CI->load->library('session');
$oauth = array();
$oauth['oauth_token_secret']='';
$oauth['oauth_token']='';
}
私の関数の直前ですが、それは何もしません..そして私はグーグルによって私のセッション変数の在庫を失うことになるのではないかと心配しています...そうではありませんか?Googleからトークンを取得しますか?