microcore/foursquare 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

microcore/foursquare

Composer 安装命令:

composer require microcore/foursquare

包简介

Foursquare Api Client

关键字:

README 文档

README

Usage

This library wrappers for php applications to make requests to both public and authenticated-only resources on Foursquare.

Querying the API

    $Foursquare = new \Foursquare\Client\FoursquareApi('<your client key>", "<your client secret>');
    $response = $Foursquare->getPublic("venues/search",array("near"=>"Montreal, Quebec"));
    pr($response);

Authenticating the user (simple)

// Generates an authentication link for you to display to your users
// (https://foursquare.com/oauth2/authenticate?...)
$auth_link = $Foursquare->getRedirectUrl();

// Converts an authentication code (sent from foursquare to your $redirect_url) into an access token
if ( ($response = $Foursquare->getTokenByCode($_REQUEST['code'])) && !isset( $response['error'] ) && isset( $response['access_token'] ) ) {
    $token = $response['access_token'];
    $Foursquare->setAccessToken($token);
}

Authenticating the user in MicroCore App

$connect = new \Foursquare\Client\FoursquareConnect($this);
if ( !empty($this->request['code']) ) {
    if ( $this->request['state'] ) {
        $base = explode( '-', $this->request['state'] );
        if(count($base) == 2){
            $this->request['state'] = $_REQUEST['state'] = $base[1];
            try {
                $connect->finishLogin($base[0]);
            } catch( Exception $error ) {
                $msg = $error->getMessage();
                switch( $msg ) {
                    default:
                        $this->View->set('error', 'Error 999990. No data received from foursquare, please register');
                        break;
                    case 'API_NOT_SET_UP':
                        $this->View->set('error', 'Error 999991. No data received from foursquare, please register');
                        break;
                    case 'NOT_REMOTE_MEMBER':
                        $this->View->set('error', 'Error 999992. No data received from foursquare, please register ');
                    break;
                    case 'CREATION_FAIL':
                        $this->View->set('error', 'Error 999993. No data received from foursquare, please register ');
                    break;
                    case 'CREATION_FAIL_TOKEN':
                        $this->View->set('error', 'Error 999994. No data received from foursquare, please register ');
                    break;
                    case 'MERGE_SOCIAL_ACCOUNT':
                        $this->View->set('error', 'Error 999995. Another user already linked his profile with this Google Account');
                    break;
                    case 'SOCIAL_NETWORK_ERROR':
                        $this->View->set('error', 'Error 999996. Foursquare has returned error');
                    break;
                }
                $this->View->errorAction('custom_error');
            }
        } else {
            $this->redirect("/login");
        }
    } else {
        $connect->finishConnection();
    }
} else {
    $connect->redirectToConnectPage();
}
$this->redirect("/login");

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPLv3
  • 更新时间: 2016-06-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固