kolovious/melisocialite
Composer 安装命令:
composer require kolovious/melisocialite
包简介
Mercadolibre Laravel Socialite Integration
README 文档
README
Laravel Socialite provider for Mercadolibre OAuth authentication.
Supports Laravel 9.x, 10.x, 11.x, and 12.x
License
Mercadolibre Laravel Socialite is open-sourced software licensed under the MIT license
Installation
composer require kolovious/meli-socialite
Configuration
Laravel 11.x & 12.x (Auto-Discovery)
For Laravel 11 and 12, the service provider and facade are automatically discovered. You can skip the manual registration steps below.
Laravel 9.x & 10.x (Manual Registration)
After installing the Socialite library, register the Kolovious\MeliSocialite\MeliSocialiteServiceProvider in your config/app.php configuration file after the Socialite Service Provider:
'providers' => [ // Other service providers... Laravel\Socialite\SocialiteServiceProvider::class, Kolovious\MeliSocialite\MeliSocialiteServiceProvider::class, ],
Also the Meli Facade is available for actions with the API
'alias' => [ // Other alias... 'Meli' => Kolovious\MeliSocialite\Facade\Meli::class, ],
You will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your config/services.php configuration file:
'meli' => [ 'client_id' => 'your-meli-app-id', 'client_secret' => 'your-meli-secret-code', 'redirect' => 'http://your-callback-url', ],
Basic Usage
Next, you are ready to authenticate users! You will need two routes: one for redirecting the user to the OAuth provider, and another for receiving the callback from the provider after authentication. We will access Socialite using the Socialite facade:
<?php 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; } }
The redirect method takes care of sending the user to the OAuth provider, while the user method will read the incoming request and retrieve the user's information from the provider.
Of course, you will need to define routes to your controller methods:
Route::get('auth/meli', 'Auth\AuthController@redirectToProvider'); Route::get('auth/meli/callback', 'Auth\AuthController@handleProviderCallback');
Retrieving User Details
Once you have a user instance, you can grab a few more details about the user:
$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
Using the Facade to make API calls.
// 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 ]);
kolovious/melisocialite 适用场景与选型建议
kolovious/melisocialite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.16k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2016 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「MercadoLibre」 「socialite」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kolovious/melisocialite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kolovious/melisocialite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kolovious/melisocialite 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Client para integração com API do Mercado Livre
Laravel Authentication package with built-in two-factor (Authy) and social authentication (Socialite).
Mercadolibre SDK Composer Package
Socialite authentication and persistence layer implementation.
TikTok Shop OAuth2 Provider for Laravel Socialite
Planning Center OAuth2 Provider for Laravel Socialite
统计信息
- 总下载量: 1.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 12
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-08