Ejemplo n.º 1
0
 /**
  * Get user media from instagram
  *
  * @see constructQuery
  *
  * @param $user_name
  * @param null $cursor_after
  * @param null $limit
  * @return array
  */
 public function get($user_name, $cursor_after = NULL, $limit = NULL)
 {
     if (!$cursor_after) {
         $resultObj = new UserInfo($this->client);
         $result = $resultObj->get($user_name);
         $this->user_id = $result->id;
     } else {
         $post_params = $this->constructQuery($user_name, $cursor_after, $limit);
         $result = $this->asObject($this->client->webRequest('/query/', 'POST', [], $post_params));
     }
     $media = ['cursor_after' => !empty($result->media->page_info->end_cursor) && !empty($result->media->page_info->has_next_page) ? $result->media->page_info->end_cursor : NULL, 'data' => !empty($result->media->nodes) ? $result->media->nodes : NULL];
     return $media;
 }
Ejemplo n.º 2
0
        if ($rt === false) {
            $rt = array('openid' => $this->openid, 'nickname' => '', 'sex' => '', 'city' => '', 'province' => '', 'country' => '', 'headimgurl' => '');
        }
        $info = (object) $rt;
        $sql = "DELETE FROM `wx_userinfo` WHERE `openid` = '{$this->openid}'";
        $this->delete($sql);
        $sql = "INSERT INTO `wx_userinfo` VALUES ('{$info->openid}', '{$info->nickname}', '{$info->sex}', '{$info->country}', '{$info->province}', '{$info->city}', '{$info->headimgurl}')";
        $this->insert($sql);
        return $rt;
    }
    private function loadByRequest()
    {
        include_once dirname(__FILE__) . '/../token/access_token.php';
        include_once dirname(__FILE__) . '/../../util/http_client.php';
        $access_token = (new AccessToken())->get();
        $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$access_token}&openid={$this->openid}&lang=zh_CN";
        $info = json_decode((new HttpClient($url))->get(), true);
        if (isset($info['subscribe']) && $info['subscribe'] == 1) {
            return array('openid' => $info['openid'], 'nickname' => $info['nickname'], 'sex' => $info['sex'], 'city' => $info['city'], 'province' => $info['province'], 'country' => $info['country'], 'headimgurl' => isset($info['headimgurl']) ? $info['headimgurl'] : '');
        } else {
            return false;
        }
    }
}
//request by developer
if (isset($_GET['userinfo']) && isset($_GET['secret']) && isset($_GET['openid'])) {
    if ($_GET['userinfo'] == APPID && $_GET['secret'] == PRIVATE_SECRET) {
        $tmp = new UserInfo($_GET['openid']);
        print_r($tmp->get());
    }
}
Ejemplo n.º 3
0
		/** 
		 * Returns a user object by open ID. Does not log a user in.
		 * @param string $uOpenID
		 * @return UserInfo
		 */
		public function getByOpenID($uOpenID) {
			return UserInfo::get('inner join UserOpenIDs on Users.uID = UserOpenIDs.uID where uOpenID = ?', $uOpenID);
		}