Package Data | |
---|---|
Maintainer Username: | jakub-klapka |
Maintainer Contact: | klapka@lumiart.cz (Jakub Klapka) |
Package Create Date: | 2017-04-07 |
Package Last Update: | 2020-12-28 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 03:03:54 |
Package Statistics | |
---|---|
Total Downloads: | 3,790 |
Monthly Downloads: | 143 |
Daily Downloads: | 12 |
Total Stars: | 7 |
Total Watchers: | 3 |
Total Forks: | 5 |
Total Open Issues: | 2 |
Simple Client for uploading files to Sharepoint Online library. Integrated Laravel Service Provider.
Uses accesscontrol.windows.net OAuth2, so it works with MS ADFS or Azure AAD Authentication.
\JakubKlapka\LaravelSharepointUploadClient\LaravelSharepointUploadProvider::class
class Controller {
protected $sharepointClient;
public function __construct( \JakubKlapka\LaravelSharepointUploadClient\Factories\ClientFactory $sharepointClient ) {
$this->sharepointClient = $sharepointClient;
}
public function upload() {
$client = $this->sharepointClient->makeClient( $site_url, $app_id, $app_secret, $redirect_uri );
}
}
You will need those attributes, you can register Sharepoint App on: https://contoso.sharepoint.com/sites/MySite/_layouts/15/appregnew.aspx
Attribute | Description | Example :---: | --- | --- site_url | Abosolute path to root of your sharepoint site | https://contoso.sharepoint.com/sites/MySite app_id | ID of your app | app_secret | Secret of your app | redirect_uri | Redirect URI has to match the one, entered on appregnew.aspx | https://myapp.com/shp-oauth/
$url = $client->getUserConsentUri()
$auth_code = $_REQUEST['code'];
$refreshToken = $client->getRefreshTokenFromAuthCode( $auth_code );
This client does not handle token persistence, feel free to save it to file/db/redis or wherever it is fit for your app.
Refresh token is valid for 6 months.
$upload_result = $client->uploadFile(
$refresh_token,
'/sites/mySite/myLibrary/',
'file.txt',
$this->transfer_storage->readStream( 'file.txt' )
);