• Stars
    star
    248
  • Rank 163,560 (Top 4 %)
  • Language
    PHP
  • License
    Other
  • Created over 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Evernote SDK for PHP

Evernote SDK for PHP

Evernote API version 1.26

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();

More Repositories

1

android-job

Android library to handle jobs in the background.
Java
5,373
star
2

android-state

A utility library for Android to save objects in a Bundle without any boilerplate.
Java
862
star
3

evernote-sdk-python

Evernote SDK for Python
Python
612
star
4

evernote-sdk-js

Evernote SDK for JavaScript
JavaScript
561
star
5

evernote-sdk-android

Evernote SDK for Android
Java
429
star
6

evernote-sdk-ios

Evernote SDK for iOS
Objective-C
398
star
7

evernote-sdk-python3

Testing the Evernote Cloud API for Python 3
Python
276
star
8

evernote-sdk-java

Evernote SDK for Java
Java
259
star
9

evernote-cloud-sdk-ios

Evernote Cloud SDK for iOS
Objective-C
256
star
10

serge

Continuous localization platform
Perl
231
star
11

evernote-sdk-ruby

Evernote SDK for Ruby
Ruby
163
star
12

evernote-cloud-sdk-php

PHP
149
star
13

evernote-sdk-csharp

Evernote SDK for C#
C#
125
star
14

evernote-thrift

Thrift IDL files for the Evernote Cloud API
Thrift
96
star
15

evernote-sdk-mac

Evernote SDK for Cocoa
Objective-C
89
star
16

evernote-sdk-cpp

Evernote SDK for C++
C++
78
star
17

evernote-cloud-sdk-windows

C#
78
star
18

evernote-oauth-ruby

Evernote OAuth / Thrift API client library for Ruby
Ruby
74
star
19

zing

Translation server for continuous localization.
Python
57
star
20

android-intent

A simple to use library for Android which helps to connect to the main Android app with Intents.
Java
42
star
21

evernote-sdk-as3

Evernote SDK for ActionScript
ActionScript
22
star
22

evernote-sdk-perl

Evernote SDK for Perl
Perl
19
star
23

Aquaman

TypeScript
18
star
24

serge-website

Source code for https://serge.io/ — documentation site for Serge
PHP
5
star
25

eslint-plugin-evernote

Evernote custom eslint plugin
JavaScript
5
star
26

eslint-config-evernote

eslint config rules for Evernote projects.
JavaScript
2
star