2011-06-28 17 views
0

TwitterのoAuthを使用してログインと登録を処理するjQuery Mobileアプリがあります。ただし、ホーム画面に追加されるiPhone Mobileアプリはセッションを処理しません。私はlocalStorageを使う必要があると言われました。ここで私の現在のコードは、セッションではなくlocalStorageへの翻訳に役立つ必要があります。どんな助けでも大歓迎です。HTML5 localStorage + Twitter oAuth

メインページ:

<?php 
require("lib/twitteroauth.php"); 
session_start(); 

if(!empty($_GET['oauth_verifier']) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret'])){ 

// TwitterOAuth instance, with two new parameters we got in twitter_login.php 
$twitteroauth = new TwitterOAuth("consumer key", "secret",$_SESSION['oauth_token'],$_SESSION['oauth_token_secret']); 
// Let's request the access token 
$access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']); 
// Save it in a session var 
$_SESSION['access_token'] = $access_token; 
// Let's get the user's info 
$user_info = $twitteroauth->get('account/verify_credentials'); 
} 
?> 

感謝を:

<?php 
require("lib/twitteroauth.php"); 
session_start(); 

// The TwitterOAuth instance 
$twitteroauth = new TwitterOAuth('consumer key','secret'); 
// Requesting authentication tokens, the parameter is the URL we will be redirected to 
$request_token = $twitteroauth->getRequestToken('login.php'); 

// Saving them into the session 
$_SESSION['oauth_token'] = $request_token['oauth_token']; 
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret']; 

// If everything goes well.. 
if($twitteroauth->http_code==200){ 
// Let's generate the URL and redirect 
$url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']); 
    header ('Location: '.$url); 
} else { 
// It's a bad idea to kill the script, but we've got to know when there's an error. 
die('Something wrong happened.'); 
} 
?> 

Twitterはそれがlogin.phpにリダイレクトログインを処理した後に!

答えて