mirror of
https://github.com/brunofontes/Memsource-API.git
synced 2024-11-24 03:07:10 +00:00
Including more information on README.md
This commit is contained in:
parent
3c6d2f0442
commit
6f19522c52
55
README.md
55
README.md
@ -25,7 +25,7 @@ Install it with [Composer](https://getcomposer.org/):
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. Run `php composer.phar install`
|
2. Run `php composer.phar install`
|
||||||
3. Add the following line on your main .php file:
|
3. Add the following line on your .php file:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
@ -34,8 +34,7 @@ require_once __DIR__ . '/vendor/autoload.php';
|
|||||||
## Using
|
## Using
|
||||||
|
|
||||||
This repository returns a JSON string for almost any command.
|
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
|
If you are not sure how to use it, just convert it to an object or an array as follows:
|
||||||
or an array as follows:
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$myObject = json_decode($response);
|
$myObject = json_decode($response);
|
||||||
@ -54,31 +53,26 @@ $memsource = new \BrunoFontes\Memsource();
|
|||||||
$memsource = new \BrunoFontes\Memsource($token);
|
$memsource = new \BrunoFontes\Memsource($token);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Basic (only for non-experienced devs)
|
|
||||||
|
|
||||||
|
|
||||||
```php
|
|
||||||
|
|
||||||
|
|
||||||
### Getting an Access Token
|
### Getting an Access Token
|
||||||
|
|
||||||
To be able to use the Memsource API, you need an **access token**, but to get it, you need to:
|
To be able to use the Memsource API, you need an **access token**. In order to get it, just follow the instructions below.
|
||||||
|
|
||||||
#### Register as a developer on Memsource website
|
#### Register as a developer on Memsource website
|
||||||
|
|
||||||
So you will receive your:
|
So you will receive your:
|
||||||
- *client id*
|
|
||||||
- *client secret*
|
- *client id*
|
||||||
|
- *client secret*
|
||||||
|
|
||||||
#### Get an Authorization Code
|
#### Get an Authorization Code
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$url = $memsource->oauth()->getAuthorizationCodeUrl($cliend_id, $callback_uri);
|
$memsourceUrl = $memsource->oauth()->getAuthorizationCodeUrl($cliend_id, $callback_uri);
|
||||||
```
|
```
|
||||||
|
|
||||||
Redirect your browser to this returned `$url` so the user can login via *oauth*.
|
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...
|
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
|
||||||
|
|
||||||
@ -87,30 +81,51 @@ $authCode = $_GET['code'];
|
|||||||
$token = $memsource->oauth()->getAccessToken($authCode, $client_id, $client_secret, $callback_uri);
|
$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
|
Safely store this `$token` with the related user data and use it to instantiate the class whenever it were necessary.
|
||||||
|
|
||||||
### Project
|
### Project
|
||||||
|
|
||||||
#### Project list
|
#### Project list
|
||||||
|
|
||||||
To list all projects...
|
To list all projects:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$projectList = $memsource->project()->listProjects;
|
$projectList = $memsource->project()->listProjects;
|
||||||
```
|
```
|
||||||
|
|
||||||
To use filters, add the API filter as parâmeter:
|
To use filters, add the API filter as parameter:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$projectList = $memsource->project()->listProjects(['name' => 'Project X']);
|
$projectList = $memsource->project()->listProjects(['name' => 'Project X']);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Job
|
#### Get Project
|
||||||
|
|
||||||
### List Jobs
|
```php
|
||||||
|
$projectList = $memsource->project()->getProject($projectUid);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Jobs
|
||||||
|
|
||||||
|
#### List Jobs
|
||||||
|
|
||||||
Only projectUid is essencial:
|
Only projectUid is essencial:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$memsource->jobs()->listJobs($projectUid, ['count' => true, 'filename' => 'my_file.html']);
|
$jobs = $memsource->jobs()->listJobs($projectUid, ['count' => true, 'filename' => 'my_file.html']);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Bilingual Files
|
### Bilingual Files
|
||||||
|
|
||||||
|
#### Download Bilingual File
|
||||||
|
|
||||||
|
```php
|
||||||
|
$memsource->BilingualFile()->downloadBilingualFile($projectUid, ['JobUid1', 'jobUid2'], 'download.mxliff');
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Upload Bilingual File
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parameters = ['format' => 'MXLF', 'saveToTransMemory' => 'None', 'setCompleted' => 'false'];
|
||||||
|
$result = $api->bilingualFile()->uploadBilingualFile('upload.mxliff', $parameters);
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user