PHP code example of olxbr / olx-api-client

1. Go to this page and download the library: Download olxbr/olx-api-client 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/ */

    

olxbr / olx-api-client example snippets



use OlxApiClient\Client;
w Client('olx_oauth_secrets.json');
if (isset($_SESSION['olx_access_token'])) {
    $dadosUsuario = $client->call('basic_user_info', json_encode(array(
        'access_token' => $_SESSION['olx_access_token']
    )));
    echo '<h1>Dados do Usuario</h1>';
    var_dump(json_decode($dadosUsuario['body']));
} else {
    echo '<a href="'.$client->createAuthUrl().'">Autentica</a>';
}


use OlxApiClient\Client;
w Client('olx_oauth_secrets.json');

if (!isset($_GET['code'])) {
    echo '<a href = '.$client->createAuthUrl().'>Autentica</a>';
} else {
    $_SESSION['olx_access_token'] = $client->authenticate($_GET['code']);
    header('Location: http://'.$_SERVER['HTTP_HOST'].'/');
}
json
{
	"client_id":"4414d3003b0794ba3dfc8da29493c8497cf352e7",
	"client_secret": "ed63d0a437cd6f9db6299ffe779bca81",
	"scope":"basic_user_info autoupload",
	"redirect_uri":"http://www.suapagina.com.br/return_page.php"
}