1. Go to this page and download the library: Download kolovious/melisocialite 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/ */
kolovious / melisocialite example snippets
'providers' => [
// Other service providers...
Laravel\Socialite\SocialiteServiceProvider::class,
Kolovious\MeliSocialite\MeliSocialiteServiceProvider::class,
],
'alias' => [
// Other alias...
'Meli' => Kolovious\MeliSocialite\Facade\Meli::class,
],
namespace App\Http\Controllers;
use Socialite;
class AuthController extends Controller
{
/**
* Redirect the user to the Meli authentication page.
*
* @return Response
*/
public function redirectToProvider()
{
return Socialite::driver('meli')->redirect();
}
/**
* Obtain the user information from Meli.
*
* @return Response
*/
public function handleProviderCallback()
{
$user = Socialite::driver('meli')->user();
// $user->token;
}
}
$user = Socialite::driver('meli')->user();
// Tokens & Expire time
$token = $user->token;
$refresh_token = $user->refresh_token;
$expires_at = $user->expires_at; // UNIX TIMESTAMP
// Methods from Socialite User
$user->getId();
$user->getNickname();
$user->getName();
$user->getEmail();
// Raw Data
$user->user // Provided by Meli
// Items from User ( ALL )
$offset = 0;
$call= "/users/".$user_id."/items/search";
$result = Meli::get($call, ["offset"=>$offset, 'access_token'=>$access_token]);
// Update Item Description
// Will use the saved access_token in the MeliManager object.
$result = Meli::withToken()->put('/items/'.$item_id.'/description', [ 'text' => $this->description ]);
or
// Will save this token for future uses. Same as above.
$result = Meli::withToken($token)->put('/items/'.$item_id.'/description', [ 'text' => $this->description ]);
or
// Will use the Access Token in the Auth user, and save it for future uses. You can call withToken() the next time and it will work as espected
$result = Meli::withAuthToken()->put('/items/'.$item_id.'/description', [ 'text' => $this->description ]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.