evernote/yinxiang 问题修复 & 功能扩展

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

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

evernote/yinxiang

Composer 安装命令:

composer require evernote/yinxiang

包简介

Yinxiang PHP SDK

README 文档

README

Evernote API version 1.25

Overview

This SDK contains wrapper code used to call the Evernote Cloud API from PHP.

The SDK also contains two samples. The code in sample/client demonstrates the basic use of the SDK for single-user scripts. The code in sample/oauth demonstrates the basic use of the SDK for web applications that authenticate using OAuth.

Prerequisites

This SDK makes use of PHP namespaces, and as such requires PHP 5.3 or later.

In order to use the code in this SDK, you need to obtain an API key from http://dev.evernote.com/documentation/cloud. You'll also find full API documentation on that page.

In order to run the sample code, you need a user account on the sandbox service where you will do your development. Sign up for an account at https://sandbox.evernote.com/Registration.action

In order to run the client sample code, you need a developer token. Get one at https://sandbox.evernote.com/api/DeveloperToken.action

Getting Started - Client

The code in sample/client/EDAMTest.php demonstrates the basics of using the Evernote API, using developer tokens to simplify the authentication process while you're learning.

  1. Open sample/client/EDAMTest.php

  2. Scroll down and fill in your Evernote developer token.

  3. On the command line, run the following command to execute the script:

    php EDAMTest.php

Getting Started - OAuth

Web applications must use OAuth to authenticate to the Evernote service. The code in sample/oauth contains a simple web app that demonstrates the OAuth authentication process.

  1. Open the file sample/oauth/config.php
  2. Fill in your Evernote API consumer key and secret.
  3. Deploy the sample/oauth directory to your web server
  4. Load the web application in your browser (e.g. http://localhost/oauth)

There are two pages in the sample. index.php demonstrates each step of the OAuth process in detail. This is useful for developers, but not what an end user would see. sampleApp.php demonstrates the simplified process, which is similar to what you would implement in your production app.

Getting Started - OAuth with Opauth

  1. Install the dependencies

    cd sample/oauth_with_opauth

    php composer.phar install

  2. Install the Strategy

    cd sample/oauth_with_opauth/vendor/opauth/opauth/lib/Opauth/Strategy/README.md

    git clone git://github.com/evernote/opauth-evernote.git Evernote

  3. Open the file sample/oauth_with_opauth/config.php

  4. Fill in your Evernote API consumer key and secret.

  5. Fill the 'dir' key as follow :

    If your url is http://localhost/oauth_with_opauth, path should be set to '/oauth_with_opauth/auth/'

  6. Deploy the sample/oauth_with_opauth directory to your web server

  7. Load the web application in your browser (e.g. http://localhost/oauth_with_opauth)

Installing SDK using Composer

Using Composer is one of the options to install Evernote SDK for PHP.

  1. Add "evernote/evernote" as a dependency in your project's composer.json file.

    {
        "require": {
            "evernote/evernote": "dev-master"
        }
    }
  2. Download and install Composer.

    curl -s "http://getcomposer.org/installer" | php

  3. Install your dependencies.

    php composer.phar install

  4. Require Composer's autoloader by adding the following line to your code's bootstrap process.

    require '/path/to/sdk/vendor/autoload.php';

Usage

OAuth

$client = new Evernote\Client(array(
  'consumerKey' => 'YOUR CONSUMER KEY',
  'consumerSecret' => 'YOUR CONSUMER SECRET'
));
$requestToken = $client->getRequestToken('YOUR CALLBACK URL');
$authorizeUrl = $client->getAuthorizeUrl($requestToken['oauth_token']);
 => https://sandbox.evernote.com/OAuth.action?oauth_token=OAUTH_TOKEN

To obtain the access token

$accessToken = $client->getAccessToken(
  $requestToken['oauth_token'],
  $requestToken['oauth_token_secret'],
  $_GET['oauth_verifier']
);

Now you can make other API calls

$token = $accessToken['oauth_token'];
$client = new Evernote\Client(array('token' => $token));
$noteStore = $client->getNoteStore();
$notebooks = $noteStore->listNotebooks();

UserStore

Once you acquire token, you can use UserStore. For example, if you want to call UserStore.getUser:

$client = new Evernote\Client(array('token' => $token));
$userStore = $client->getUserStore();
$userStore->getUser();

You can omit authenticationToken in the arguments of UserStore/NoteStore functions.

NoteStore

If you want to call NoteStore.listNotebooks:

$noteStore = $client->getNoteStore();
$noteStore->listNotebooks();

NoteStore for linked notebooks

If you want to get tags for linked notebooks:

$linkedNotebooks = $noteStore->listLinkedNotebooks;
$linkedNotebook = $linkedNotebooks[0];
$sharedNoteStore = $client->sharedNoteStore($linkedNotebook);
$sharedNotebook = $sharedNoteStore->getSharedNotebookByAuth();
$sharedNoteStore->listTagsByNotebook($sharedNotebook->notebookGuid);

NoteStore for Business

If you want to get the list of notebooks in your business account:

$businessNoteStore = $client->getBusinessNoteStore();
$businessNoteStore->listNotebooks();

evernote/yinxiang 适用场景与选型建议

evernote/yinxiang 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 evernote/yinxiang 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache
  • 更新时间: 2015-02-20