PHP code example of navneetrai / laravel-submitter
1. Go to this page and download the library: Download navneetrai/laravel-submitter 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/ */
navneetrai / laravel-submitter example snippets
'providers' => [
// ...
Userdesk\Submission\SubmissionServiceProvider::class,
]
'aliases' => [
// ...
'Submission' => Userdesk\Submission\Facades\Submission::class,
]
return [
/*
|--------------------------------------------------------------------------
| Submission Config
|--------------------------------------------------------------------------
*/
/**
* Services
*/
'services' => [
'facebook' => [
'client_id' => '',
'client_secret' => '',
'scope' => ['email', 'public_profile', 'publish_actions'],
],
'twitter' => [
'client_id' => '',
'client_secret' => '',
// No scope - oauth1 doesn't need scope
],
'youtube' => [
'client_id' => '',
'client_secret' => '',
'scope' => [
'profile', 'email',
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.upload',
'https://www.googleapis.com/auth/youtube.readonly'
],
],
]
];
$submitter = Submission::submitter('twitter');
$submitter = Submission::submitter($website);
return $submitter->authenticate($state);
Route::get('/any-base-url-of-your-liking/{website}/{state?}', ['as'=>'package.Userdesk.submission.authenticate', 'uses'=>'YourSubmissionController@authenticate']);
public function authenticate(Request $request, String $website, int $state = 0){
$submitter = Submission::submitter($website);
try{
$credentials = $submitter->completeAuthentication($request, $state);
}catch(InvalidTokenException $e){
//Check configuration variables.
}catch(InvalidPrivilegeException $e){
//Flash message to user that he needs to provide
$submitter = Submitter::submitter($website);
$token = new SubmissionToken();
$token->addTokenArray($tokenArray);
$submitter->addToken($token);
try{
$submitter = Submitter::submitter($website);
$token = new SubmissionToken();
$token->addTokenArray($tokenArray);
$video = new SubmissionVideoItem($title, $description, $localThumb, $localVideo, $keywords);
$submitter->addToken($token);
$result = $submitter->uploadVideo($video);
$status = $result->getStaus();
$url = $result->getUrl();
}catch(InvalidUploadException $e){
Log::error($e->getMessage());
}
$submitter = Submitter::submitter($website);
try{
$token = new SubmissionToken();
$token->addTokenArray($tokenArray);
$image = new SubmissionImageItem($title, $description, $localImage, $keywords);
$submitter->addToken($token);
$result = $submitter->uploadImage($image);
$status = $result->getStaus();
$url = $result->getUrl();
}catch(InvalidUploadException $e){
Log::error($e->getMessage());
}
$submitter = Submitter::submitter($website);
try{
$token = new SubmissionToken();
$token->addTokenArray($tokenArray);
$link = new SubmissionLinkItem($title, $description, $link, $keywords);
$submitter->addToken($token);
$result = $submitter->addLink($link);
$status = $result->getStaus();
$url = $result->getUrl();
}catch(InvalidUploadException $e){
Log::error($e->getMessage());
}
$submitter = Submitter::submitter($website);
try{
$token = new SubmissionToken();
$token->addTokenArray($tokenArray);
$update = new SubmissionStatusItem($title, $status, $keywords);
$submitter->addToken($token);
$result = $submitter->addStatus($update);
$status = $result->getStaus();
$url = $result->getUrl();
}catch(InvalidUploadException $e){
Log::error($e->getMessage());
}
config/app.php
config/app.php
$ php artisan vendor:publish --provider="Userdesk\Submission\SubmissionServiceProvider"