zechdc/oauth1-etrade 问题修复 & 功能扩展

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

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

zechdc/oauth1-etrade

Composer 安装命令:

composer require zechdc/oauth1-etrade

包简介

ETrade OAuth 1.0 Client Provider for The PHP League OAuth1-Client

README 文档

README

This package provides Etrade OAuth 1.0 support for the PHP League's OAuth 1.0 Client.

Installation

To install, use composer:

composer require zechdc/oauth1-etrade

Usage

Usage is the same as The League's OAuth client, using Zechdc\OAuth1\Client\Server\Etrade as the provider.

You must contact Etrade to setup your callback URL.

//Step 1, setup an Etrade instance
$server = new Zechdc\OAuth1\Client\Server\Etrade(array(
    'identifier'   => 'oauth_customer_key',
    'secret'       => 'consumer_secret',
));

//Step 2, get create your Request Token ($temporaryCredentials)
public function getRequestTokenAndAuthorizeApplication(){

    //This creates your Request Token
    $temporaryCredentials = $this->server->getTemporaryCredentials();
    
    //Save the $temporaryCredentials in a session or DB to be used later.
    Session::set('temporary_credentials', $temporaryCredentials);
    
    //This will allow the user to Authorize your Application. It will redirect the user
    //to etrade. After they login and accept your application, it will either
    // 1) Redirect to your website - this requires you to contact etrade customer support and setup a callback url
    // 2) Etrade will show you a code called the oauth_verifier which you can manually copy into the next step.
    $this->server->authorize($temporaryCredentials);
}

//Step 3, use the request token ($temporaryCredentials) and the oauth_verifier provided by etrade to create your Access Token
public function getAccessToken(){
    //Get our temporary credentials from our storage
    $temporaryCredentials = Session::get('temporary_credentials');
    $requestToken = $temporaryCredentials->getIdentifier();
    
    //The code the user received after authorizing the application.
    $oauthVerifier = $_GET['oauth_verifier'];
    
    //This gets our Access Token
    $tokenCredentials = $this->server->getTokenCredentials($temporaryCredentials, $requestToken, $oauthVerifier);
    
    //Save the Access Token so we can make and authorize more API calls. 
    Session::set('token_credentials', $tokenCredentials);
}

//Step 4, now that you have your Access Token, lets call an endpoint
public function getMarketData(){
    $client = new Guzzle\Client();
    $accessToken = Session::get('token_credentials');
    $url = "https://etwssandbox.etrade.com/market/sandbox/rest/quote/GOOGL.json";
    $method = 'GET';
    $params = ['detailFlag' => 'FUNDAMENTAL'];
    
    //This constructs our Authorization header and the oauth signature.
    $headers = $this->server->getHeaders($accessToken, $method, $url, $params);
  
    $res = $client->request($method, $url, [
      'headers' => $headers,
      'query' => $params
    ]);
    
    echo $res->getStatusCode();
    echo $res->getBody();
}

zechdc/oauth1-etrade 适用场景与选型建议

zechdc/oauth1-etrade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 50 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「authorization」 「client」 「oauth」 「oauth1」 「authorisation」 「stocks」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 zechdc/oauth1-etrade 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 zechdc/oauth1-etrade 我们能提供哪些服务?
定制开发 / 二次开发

基于 zechdc/oauth1-etrade 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-13