2010-08-20 12 views
6

इम यहां पाया ट्विटर OAuth वर्ग का उपयोग ट्विटर से कनेक्ट करने के:ट्विटर OAuth - MySql में संग्रहीत टोकन

वर्तमान में स्क्रिप्ट सिर्फ टोकन आपूर्ति का उपयोग करता है लेकिन, मैं करने के लिए स्क्रिप्ट करना चाहते हैं नहीं करता है उन्हें एक डेटाबेस में स्टोर यह करो। स्क्रिप्ट के कौन से भाग रहा टोकन मिलता है में

<?php 
/** 
* @file 
* Take the user when they return from Twitter. Get access tokens. 
* Verify credentials and redirect to based on response from Twitter. 
*/ 

/* Start session and load lib */ 
session_start(); 
require_once('twitteroauth/twitteroauth.php'); 
require_once('config.php'); 

/* If the oauth_token is old redirect to the connect page. */ 
if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) { 
    $_SESSION['oauth_status'] = 'oldtoken'; 
    header('Location: ./clearsessions.php'); 
} 

/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */ 
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); 

/* Request access tokens from twitter */ 
$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']); 

/* Save the access tokens. Normally these would be saved in a database for future use. */ 
$_SESSION['access_token'] = $access_token; 

/* Remove no longer needed request tokens */ 
unset($_SESSION['oauth_token']); 
unset($_SESSION['oauth_token_secret']); 

/* If HTTP response is 200 continue otherwise send to connect page to retry */ 
if (200 == $connection->http_code) { 
    /* The user has been verified and the access tokens can be saved for future use */ 
    $_SESSION['status'] = 'verified'; 
    header('Location: ./index.php'); 
} else { 
    /* Save HTTP status for error dialog on connnect page.*/ 
    header('Location: ./clearsessions.php'); 
} 

मैं MySql के लिए टोकन कैसे बचा सकते हैं,:

यह है कि मैं क्या वर्तमान में मेरे कॉलबैक लिपि में है?

उत्तर

6

आपको जिस डेटा की आवश्यकता है वह $_SESSION['access_token'] = $access_token; चर में संग्रहीत है।

आप पाएंगे print_r($access_token);

प्रयास करें कि चर के अंदर:

screen_name 
user_id 
oauth_token 
oauth_token_secret 

कौन सा अपने अनुप्रयोग के लिए इस्तेमाल किया जा सकता है और अपने डेटाबेस में संग्रहीत।

संबंधित मुद्दे