mirror of
https://github.com/brunofontes/Memsource-API.git
synced 2024-11-23 19:00:50 +00:00
Improving README.md file
This commit is contained in:
parent
7f2132515b
commit
3c6d2f0442
90
README.md
90
README.md
@ -4,20 +4,75 @@ I am creating this Memsource API as a way to learn how to deal with one and to u
|
||||
|
||||
There are other Memsource API repositories on GibHub that appears to be fully functional if you need it.
|
||||
|
||||
## Getting an Access Token
|
||||
## Installing
|
||||
|
||||
To be able to use the Memsource API, you need an **access token**, but to get it, you need to:
|
||||
Install it with [Composer](https://getcomposer.org/):
|
||||
|
||||
### Register as a developer on Memsource website
|
||||
1. Create a `composer.json` file with the following content:
|
||||
|
||||
So you will receive your:
|
||||
- *client id*
|
||||
- *client secret*
|
||||
```json
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/brunofontes/Memsource-API"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"brunofontes/memsource-api": "*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Get an Authorization Code
|
||||
2. Run `php composer.phar install`
|
||||
3. Add the following line on your main .php file:
|
||||
|
||||
```php
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
```
|
||||
|
||||
## Using
|
||||
|
||||
This repository returns a JSON string for almost any command.
|
||||
If you are not sure how to use it, just convert it to an object
|
||||
or an array as follows:
|
||||
|
||||
```php
|
||||
$myObject = json_decode($response);
|
||||
$myArray = json_decode($response, true);
|
||||
```
|
||||
|
||||
### Create an instance
|
||||
|
||||
```php
|
||||
$memsource = new \BrunoFontes\Memsource();
|
||||
```
|
||||
|
||||
- If you have already an access token, just include it:
|
||||
|
||||
```php
|
||||
$memsource = new \BrunoFontes\Memsource($token);
|
||||
```
|
||||
|
||||
### Basic (only for non-experienced devs)
|
||||
|
||||
|
||||
```php
|
||||
|
||||
|
||||
### Getting an Access Token
|
||||
|
||||
To be able to use the Memsource API, you need an **access token**, but to get it, you need to:
|
||||
|
||||
#### Register as a developer on Memsource website
|
||||
|
||||
So you will receive your:
|
||||
- *client id*
|
||||
- *client secret*
|
||||
|
||||
#### Get an Authorization Code
|
||||
|
||||
```php
|
||||
$url = $memsource->oauth()->getAuthorizationCodeUrl($cliend_id, $callback_uri);
|
||||
```
|
||||
|
||||
@ -25,32 +80,37 @@ Redirect your browser to this returned `$url` so the user can login via *oauth*.
|
||||
|
||||
The `$callback_uri` will be called by **Memsource** with a `$_GET['code']` that contains your Authorization Code, which you can use to...
|
||||
|
||||
### Get an Access Token
|
||||
#### Get an Access Token
|
||||
|
||||
```php
|
||||
$authCode = $_GET['code'];
|
||||
$memsource = new \BrunoFontes\Memsource();
|
||||
$token = $memsource->oauth()->getAccessToken($authCode, $client_id, $client_secret, $callback_uri);
|
||||
```
|
||||
|
||||
Safely store this `$token` with the related user data and use it on any
|
||||
|
||||
## Project
|
||||
|
||||
### Project list
|
||||
### Project
|
||||
#### Project list
|
||||
|
||||
To list all projects...
|
||||
|
||||
```php
|
||||
$memsource = new \BrunoFontes\Memsource();
|
||||
$projectList = $memsource->project()->listProjects;
|
||||
```
|
||||
|
||||
To use filters, add the API filter as parâmeter:
|
||||
|
||||
```php
|
||||
$projectList = $memsource->project()->listProjects(['name' => 'Project X']);
|
||||
```
|
||||
|
||||
## Bilingual Files
|
||||
### Job
|
||||
|
||||
### List Jobs
|
||||
|
||||
Only projectUid is essencial:
|
||||
```php
|
||||
$memsource->jobs()->listJobs($projectUid, ['count' => true, 'filename' => 'my_file.html']);
|
||||
```
|
||||
|
||||
### Bilingual Files
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user