set_debug() публичный Метод

开启调试信息后,SDK会将每次请求微博API所发送的POST Data、Headers以及请求信息、返回内容输出出来。
public set_debug ( boolean $enable ) : void
$enable boolean 是否开启调试信息
Результат void
Пример #1
0
 function get_info()
 {
     if ($this->dx_auth->is_logged_in()) {
         echo "你已经登陆了";
     } else {
         $this->load->model('m_open');
         session_start();
         require_once APPPATH . 'libraries/weibo/config.php';
         require_once APPPATH . 'libraries/weibo/saetv2.ex.class.php';
         $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
         $o->set_debug(DEBUG_MODE);
         if (isset($_REQUEST['code'])) {
             $keys = array();
             // 验证state
             $state = $_REQUEST['state'];
             if (empty($state) || $state !== $_SESSION['weibo_state']) {
                 echo '非法请求!';
                 exit;
             }
             unset($_SESSION['weibo_state']);
             $keys['code'] = $_REQUEST['code'];
             $keys['redirect_uri'] = WB_CALLBACK_URL;
             try {
                 $token = $o->getAccessToken('code', $keys);
             } catch (OAuthException $e) {
             }
         }
         if ($token) {
             $_SESSION['token'] = $token;
             setcookie('weibojs_' . $o->client_id, http_build_query($token));
             //echo "success";
             $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
             $c->set_debug(DEBUG_MODE);
             $uid_get = $c->get_uid();
             $uid = $uid_get['uid'];
             if (!$uid) {
                 echo "error";
             }
             $user = $c->show_user_by_id($uid);
             //根据ID获取用户等基本信息
             //echo $user['screen_name'];
             if ($this->m_open->is_id($uid)) {
                 $this->m_open->login($uid);
                 //echo "登陆";
                 //echo $uid;
                 //$c->update( "坑爹的api终于调好了");
                 redirect('line');
             } else {
                 $this->m_open->register($user);
                 $this->m_open->create($user);
                 //echo $uid;
                 //echo "注册";
                 redirect('line');
             }
         } else {
             echo "fail";
         }
     }
 }
Пример #2
0
 function open()
 {
     session_start();
     require_once APPPATH . 'libraries/weibo/config.php';
     require_once APPPATH . 'libraries/weibo/saetv2.ex.class.php';
     $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $o->set_debug(DEBUG_MODE);
     if (isset($_REQUEST['code'])) {
         $keys = array();
         // 验证state
         $state = $_REQUEST['state'];
         if (empty($state) || $state !== $_SESSION['weibo_state']) {
             echo '非法请求!';
             exit;
         }
         unset($_SESSION['weibo_state']);
         $keys['code'] = $_REQUEST['code'];
         $keys['redirect_uri'] = WB_CALLBACK_URL;
         try {
             $token = $o->getAccessToken('code', $keys);
         } catch (OAuthException $e) {
         }
     }
     if ($token) {
         $_SESSION['token'] = $token;
         setcookie('weibojs_' . $o->client_id, http_build_query($token));
         echo "success";
         $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
         $c->set_debug(DEBUG_MODE);
         $uid_get = $c->get_uid();
         $uid = $uid_get['uid'];
         $user = $c->show_user_by_id($uid);
         //根据ID获取用户等基本信息
         echo $user['screen_name'];
         //利用一个方法将weibo_id存入users
         //利用一个方法将weibo个人信息存入info中
     } else {
         echo "fail";
     }
 }
Пример #3
0
<?php

session_start();
include_once 'config.php';
include_once 'saetv2.ex.class.php';
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
$c->set_debug(DEBUG_MODE);
$ms = $c->home_timeline();
// done
//var_dump($ms);
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
?>
<!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" />
<title>新浪微博V2接口演示程序-Powered by Sina App Engine</title>
</head>

<body>
	<?php 
echo $user_message['screen_name'];
?>
,您好! 
	<h2 align="left">发送新微博</h2>
	<form action="" >
		<input type="text" name="text" style="width:300px" />
		<input type="submit" />