<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class CsdjDenglu extends CI_Model{

    public function __construct() {
	parent:: __construct ();
	$this->load->library('session'); //加载session
    }

    public  function qqlogin() {
           $url='https://graph.qq.com/oauth2.0/authorize';
           $QQ['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
           $this->session->set_userdata($QQ);

           $scope= "get_user_info,add_weibo";
           $login_url=$url.'?response_type=code&client_id='.CS_Qqid.'&redirect_uri='.site_url("open/qq_callback").'&state='.$QQ['state'].'&scope='.$scope;
           header("Location:$login_url");
    }

    public  function weibologin() {
              echo "
		<!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=gbk\" />
		<title>新浪微博登入</title>
		</head>
		<script src=\"http://tjs.sjs.sinajs.cn/t35/apps/opent/js/frames/client.js\" language=\"JavaScript\"></script>
		<script> 
		function authLoad(){
			App.AuthDialog.show({
			client_id : '".CS_Wappid."',    //必选，appkey
			redirect_uri : '".site_url('denglu/weibo_callback')."',     //必选，授权后的回调地址
			height: 120    //可选，默认距顶端120px
			});
		}
		</script>
		<body onload=\"authLoad();\">
		</body>
		</html>";
    }

    public  function baidulogin() {
            $login_url='https://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id='.CS_Bappid.'&redirect_uri='.site_url("open/baidu_callback").'&scope=netdisk&display=';
            header("Location:$login_url");
    }

    public  function renrenlogin() {
            $ren['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
            $this->session->set_userdata($ren);
            $login_url="http://graph.renren.com/oauth/authorize?client_id=".CS_Rappid."&redirect_uri=".site_url("open/renren_callback")."&response_type=code&state=".$ren['state']."&display=&x_renew=";
            header("Location:$login_url");
    }

    public  function kaixinlogin() {
            $kaixin['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
            $this->session->set_userdata($kaixin);
            $login_url="http://api.kaixin001.com/oauth2/authorize?response_type=code&client_id=".CS_Kappid."&redirect_uri=".site_url("open/kaixin_callback")."&state=".$kaixin['state']."&scope=basic&display=popup";
            header("Location:$login_url");
    }

}