Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update Readme.md
Remove get token to set credential
  • Loading branch information
flericheux committed Jan 12, 2016
1 parent 17f5869 commit ec14cf1
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 123 deletions.
57 changes: 54 additions & 3 deletions README.md
Expand Up @@ -5,16 +5,67 @@ PHP wrapper to call Digitaleo APIs, two wrappers are available
* v1/Digitaleo.php => DEPRECATED
* v2/Digitaleo.php

Sample code to use DigitaleoOauth.php :
## Sample code to use v2/Digitaleo.php

**Init Digitaleo as password credential**

```php
$httpClient = new DigitaleoOauth();
$httpClient = new \Digitaleo();
$httpClient->setBaseUrl('<api_base_url>')
$httpClient->setOauthPasswordCredentials(
'https://oauth.messengeo.net/token',
'<client_id>',
'<client_secret>',
'<login>',
'<password>');
$httpClient->callGet('my_resource_name');
```

**Read one or several resource**

```php
$params = [
'properties' => '<properties>',
'limit' => '<limit>',
'offset' => '<limit>',
'sort' => '<sort>',
'total' => '<total>',
'<property_name1' => 'property_value1',
'<property_name2' => 'property_value2'
];
$httpClient->callGet('my_resource_name', $params);
```
**Create one resource**
```php
$body = [
'<property_name1' => 'property_value1',
'<property_name2' => 'property_value2'
];
$httpClient->callPost('my_resource_name', $body);
```
**Update one resource**
```php
$params = [
'id' => '<id_value>',
];
$dataToUpdate = [
'<property_name1' => 'property_value1',
'<property_name2' => 'property_value2'
];
$body = [
'metaData' => json_encode($dataToUpdate),
];
$httpClient->callPut('my_resource_name', $body, $params);
```
**Delete one resource**
```php
$params = [
'id' => '<id_value>'
];
$httpClient->callDelete('my_resource_name', $params);
```

0 comments on commit ec14cf1

Please sign in to comment.