Skip to content

Commit

Permalink
fixing some sample app errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SidneyAllen committed Sep 9, 2019
1 parent 9965924 commit 91c9c35
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Coming soon

All third party libraries dependencies managed with Composer.

[SDK reference](https://github.com/XeroAPI/xero-php-oauth2/tree/master/docs) for all methods and models.

## Requirements

PHP 5.5 and later
Expand All @@ -32,7 +34,7 @@ Follow these steps to create your Xero app
* Agree to terms and condition and click "Create App".
* Click "Generate a secret" button.
* Copy your client id and client secret and save for use later.
* Click the "Save" button. You secret is now hidden.
* Click the "Save" button. Your secret is now hidden.


## Installation & Usage
Expand All @@ -57,8 +59,11 @@ Download the files and include `autoload.php`:
```

## How to use the xero-php-oauth2 SDK
Below is a barebones example of the oAuth 2 flow. You can copy/paste the 4 files below and substitute your ClientId, ClientSecret and RedirectURI from developer.xero.com.

See [SDK reference](https://github.com/XeroAPI/xero-php-oauth2/tree/master/docs) for all methods and models
1. Point your browser to authorization.php, you'll be redirected to Xero where you'll login and select a Xero org to authorize.
2. Once complete, you'll be returned to your app to the redirect URI which should point to the callback.php.
3. In the callback, you'll obtain an access token which we'll use in authorizedResource.php to

### authorization.php

Expand Down Expand Up @@ -161,7 +166,7 @@ See [SDK reference](https://github.com/XeroAPI/xero-php-oauth2/tree/master/docs)
$accessToken->getRefreshToken()
);

header('Location: ' . './get.php');
header('Location: ' . './authorizedResource.php');
exit();

} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
Expand Down Expand Up @@ -299,16 +304,9 @@ class StorageClass
);

// Get all Account
$getAccountResponse = $apiInstance->getAccounts($xeroTenantId);

// Create Account
$account = new XeroAPI\XeroPHP\Models\Accounting\Account;
$account->setCode($this->getRandNum());
$account->setName("Foo" . $this->getRandNum());
$account->setType("EXPENSE");
$account->setDescription("Hello World");
$createAccountResponse = $apiInstance->createAccount($xeroTenantId,$account);

$apiResponse = $apiInstance->getOrganisations($xeroTenantId);
var_dump($apiResponse);

?>
```

Expand Down

0 comments on commit 91c9c35

Please sign in to comment.