PHP code example of ma-residence / php-sdk

1. Go to this page and download the library: Download ma-residence/php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ma-residence / php-sdk example snippets




use MR\SDK\Client;

$host = 'https://api.ensembl.fr/';
$clientId = 'CLIENT_ID';
$clientSecret = 'CLIENT_SECRET';

$mrClient = new Client($host, $clientId, $clientSecret);



$storage = new MyTokenStorage();
$mrClient = new Client($host, $clientId, $clientSecret, $storage);

$mrClient->auth()->loginWithCredentials('[email protected]', 'password');

$mrClient->auth()->loginWithExternalToken('facebook', 'FACEBOOK_ACCESS_TOKEN');

$mrClient->auth()->logout();

$mrClient->myEndpoint()->foo();

// GET Request
$mrClient->request()->get('/foo', [ 'id' => $id ]);

// POST Request
$mrClient->request()->post('/foo', [], [
    'field_a' => 'A',
    'field_b' => 'B',
]);

// PUT Request
$mrClient->request()->put('/foo', [], [
    'field_a' => 'AA',
    'field_b' => 'BB',
]);

// PATCH Request
$mrClient->request()->patch('/foo', [], [
    'field_b' => 'C',
]);

// DELETE Request
$mrClient->request()->delete('/foo');
json
{
    "a-residence/php-sdk": "2.0.*"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "https://github.comma-residence/php-sdk.git",
            "no-api": true
        }
    ]
}