Beispiel #1
0
     echo 'oauth_token_secret: ', OpenSDK_Sina_Weibo::getParam(OpenSDK_Sina_Weibo::OAUTH_TOKEN_SECRET), '<br />';
     echo '你的微博帐号信息为:<br /><pre>';
     //	var_dump($uinfo);
     /**
      * 上传一张图片,并发微博
      */
     var_dump(OpenSDK_Sina_Weibo::call('statuses/upload', array('status' => 'test pic'), 'POST', array('pic' => dirname(__FILE__) . '/0.jpg')));
     $exit = true;
 } else {
     if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
         //从Callback返回时
         if (OpenSDK_Sina_Weibo::getAccessToken($_GET['oauth_verifier'])) {
             $uinfo = OpenSDK_Sina_Weibo::call('users/show/' . OpenSDK_Sina_Weibo::getParam(OpenSDK_Sina_Weibo::OAUTH_USER_ID));
             echo '从Opent返回并获得授权。你的微博帐号信息为:<br />';
             echo 'Access token: ', OpenSDK_Sina_Weibo::getParam(OpenSDK_Sina_Weibo::ACCESS_TOKEN), '<br />';
             echo 'oauth_token_secret: ', OpenSDK_Sina_Weibo::getParam(OpenSDK_Sina_Weibo::OAUTH_TOKEN_SECRET), '<br />';
             echo '你的微博帐号信息为:<br /><pre>';
             var_dump($uinfo);
         } else {
             echo '获得Access Tokn 失败';
         }
         $exit = true;
     } else {
         if (isset($_GET['go_oauth'])) {
             $callback = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
             $request_token = OpenSDK_Sina_Weibo::getRequestToken($callback);
             !$request_token && exit('获取request_token失败,请检查网络或者appkey和appsecret是否正确');
             $url = OpenSDK_Sina_Weibo::getAuthorizeURL($request_token);
             header('Location: ' . $url);
         } else {
             echo 'sina微博OAuth1.0接口演示<a href="?go_oauth">点击去授权</a>';