コード例 #1
0
ファイル: go.php プロジェクト: xxf1995/alphaV
     // OAuth V2
     // $_SESSION['wp_url_login'] = $bind;
     if (SINA_APP_KEY == $sina_app_key_default) {
         // 默认key
         $aurl = "http://smyx.sinaapp.com/connect.php?client_id=" . SINA_APP_KEY . "&redirect_to=" . urlencode(plugins_url('wp-connect/go.php'));
     } else {
         // 自定义key
         $_SESSION['source_receiver'] = 'wp-connect/go.php';
         $aurl = "https://api.weibo.com/oauth2/authorize?client_id=" . SINA_APP_KEY . "&redirect_uri=" . urlencode(plugins_url('wp-connect/dl_receiver.php')) . "&response_type=code&scope=follow_app_official_microblog";
     }
     header('Location:' . $aurl);
     die;
 } elseif (isset($_GET['code'])) {
     $keys = array();
     class_exists('OAuthV2') or (require dirname(__FILE__) . "/OAuth/OAuthV2.php");
     $o = new OAuthV2(SINA_APP_KEY, SINA_APP_SECRET);
     $keys['code'] = $_GET['code'];
     $keys['access_token_url'] = 'https://api.weibo.com/oauth2/access_token';
     if (!empty($_SESSION['source_receiver'])) {
         $keys['redirect_uri'] = plugins_url('wp-connect/dl_receiver.php');
         $_SESSION['source_receiver'] = "";
     } else {
         $keys['redirect_uri'] = "http://smyx.sinaapp.com/receiver.php";
     }
     $token = $o->getAccessToken($keys);
     if ($token['access_token']) {
         $oauth_token = array('access_token' => $token['access_token'], 'expires_in' => BJTIMESTAMP + $token['expires_in']);
         if ($redirect_to == WP_CONNECT) {
             update_option('wptm_sina', $oauth_token);
         } elseif ($_SESSION['user_id']) {
             update_usermeta($_SESSION['user_id'], 'wptm_sina', $oauth_token);
コード例 #2
0
ファイル: OAuthV2.php プロジェクト: liangwei1988/wordpress
 /**
  * @ignore
  */
 public static function build_http_query_multi($params)
 {
     if (!$params) {
         return '';
     }
     uksort($params, 'strcmp');
     $pairs = array();
     self::$boundary = $boundary = uniqid('------------------');
     $MPboundary = '--' . $boundary;
     $endMPboundary = $MPboundary . '--';
     $multipartbody = '';
     foreach ($params as $parameter => $value) {
         if (in_array($parameter, array('pic', 'image')) && $value[0] == '@') {
             $url = ltrim($value, '@');
             $content = file_get_contents($url);
             $array = explode('?', basename($url));
             $filename = $array[0];
             $multipartbody .= $MPboundary . "\r\n";
             $multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
             $multipartbody .= "Content-Type: image/unknown\r\n\r\n";
             $multipartbody .= $content . "\r\n";
         } else {
             $multipartbody .= $MPboundary . "\r\n";
             $multipartbody .= 'content-disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
             $multipartbody .= $value . "\r\n";
         }
     }
     $multipartbody .= $endMPboundary;
     return $multipartbody;
 }