Login   Register  
PHP Classes
elePHPant
Icontem

File: qq-sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of mehmet emin akyüz  >  QQ  >  qq-sample.php  >  Download  
File: qq-sample.php
Role: Example script
Content type: text/plain
Description: a sample script to demonstrate how to connect, authorize and get user information
Class: QQ
Get QQ network user profile using OAuth tokens
Author: By
Last change: remove real appid & appkey
Date: 2012-11-25 16:06
Size: 1,211 bytes
 

Contents

Class file image Download
<?php
require_once "QQ.php";
session_start();

if( !isset( 
$_SESSION['qq'] ) ){
    
$qq = new QQ();
    
$qq->appId 'yourappid';
    
$qq->appKey 'yourappkey';
    
$qq->redirectUri $_SERVER['HTTP_HOST'];

    
$_SESSION['qq'] = $qq;
} else {
    
$qq $_SESSION['qq'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<?php if( !isset( $_REQUEST['code'] ) && $qq->accessToken == null ){
    
$qqLoginUrl $qq->getLoginUrl'get_user_info,email' );
    
$_SESSION['qq'] = $qq;
?>
<a href="<?=$qqLoginUrl?>">qq login</a>
<?php } else {
    if( !
$qq->userInfo ){
        if( 
$qq->getToken() ){
            echo 
"Token:" $qq->accessToken "<br />";
            if( 
$qq->getUser() ){
                echo 
"OpenId:" $qq->openId "<br />";
?>
            <pre style="text-align:left;">
                <?=print_r$qq->userInfotrue );?>
            </pre>
<?php        } else {
                
print_r$qq->error );
            }
        }
    } else {
    
?>
    <pre style="text-align:left;">
        <?=print_r$qq->userInfotrue );?>
    </pre>
    <?php
    
}
}
?>

</body>
</html>