
Product
/Security News
Introducing Socket Calm: A Syntax Highlighting Theme for VS Code, Vim, and Neovim
Socket Calm is a free, open source syntax highlighting theme for VS Code, Vim, and Neovim, inspired by Socket's design system.
trunks07/youtube-laravel-api
Advanced tools
It is a wrapper over Youtube Api v3 which simplifies functionalities the laravel way.
PHP (Laravel) Package for Google / YouTube API V3 with Google Auth
composer require trunks07/youtube-laravel-api
Add Service provider to config/app.php provider's array:
trunks07\YoutubeLaravelApi\YoutubeLaravelApiServiceProvider::class
Execute the following command to get the configurations:
php artisan vendor:publish --tag='youtube-config'
https://console.developers.google.comAPI key from credentials tab.product name(your site name).you site url.add a url which you want the auth code to return(login callback)
<?php
namespace Your\App\NameSpace;
use trunks07\YoutubeLaravelApi\AuthenticateService;
$authObject = new AuthenticateService;
# Replace the identifier with a unqiue identifier for account or channel
$authUrl = $authObject->getLoginUrl('email','identifier');
$code = Input::get('code');
$identifier = Input::get('state');
$authObject = new AuthenticateService;
$authResponse = $authObject->authChannelWithCode($code);
$authResponse['token'] (Channel Token)
$authResponse['channel_details']
$authResponse['live_streaming_status'] (enabled or disabled)
<?php
namespace Your\App\NameSpace;
use trunks07\YoutubeLaravelApi\LiveStreamService;
# data format creating live event
$data = array(
"title" => "",
"description" => "",
"thumbnail_path" => "", // Optional
"event_start_date_time" => "",
"event_end_date_time" => "", // Optional
"time_zone" => "",
'privacy_status' => "", // default: "public" OR "private"
"language_name" => "", // default: "English"
"tag_array" => "" // Optional and should not be more than 500 characters
);
$ytEventObj = new LiveStreamService();
/**
* The broadcast function returns array of details from YouTube.
* Store this information & will be required to supply to youtube
* for live streaming using encoder of your choice.
*/
$response = $ytEventObj->broadcast($authToken, $data);
if ( !empty($response) ) {
$youtubeEventId = $response['broadcast_response']['id'];
$serverUrl = $response['stream_response']['cdn']->ingestionInfo->ingestionAddress;
$serverKey = $response['stream_response']['cdn']->ingestionInfo->streamName;
}
$ytEventObj = new LiveStreamService();
/**
* The updateBroadcast response give details of the youtube_event_id,server_url and server_key.
* The server_url & server_key gets updated in the process. (save the updated server_key and server_url).
*/
$response = $ytEventObj->updateBroadcast($authToken, $data, $youtubeEventId);
// $youtubeEventId = $response['broadcast_response']['id'];
// $serverUrl = $response['stream_response']['cdn']->ingestionInfo->ingestionAddress;
// $serverKey = $response['stream_response']['cdn']->ingestionInfo->streamName
$ytEventObj = new LiveStreamService();
# Deleting the event requires authentication token for the channel in which the event is created and the youtube_event_id
$ytEventObj->deleteEvent($authToken, $youtubeEventId);
$ytEventObj = new LiveStreamService();
/**
* $broadcastStatus - ["testing", "live"]
* Starting the event takes place in 3 steps
* 1. Start sending the stream to the server_url via server_key recieved as a response in creating the event via the encoder of your choice.
* 2. Once stream sending has started, stream test should be done by passing $broadcastStatus="testing" & it will return response for stream status.
* 3. If transitioEvent() returns successfull for testing broadcast status, then start live streaming your video by passing $broadcastStatus="live"
* & in response it will return us the stream status.
*/
$streamStatus = $ytEventObj->transitionEvent($authToken, $youtubeEventId, $broadcastStatus);
$ytEventObj = new LiveStreamService();
/**
* $broadcastStatus - ["complete"]
* Once live streaming gets started succesfully. We can stop the streaming the video by passing broadcastStatus="complete" and in response it will give us the stream status.
*/
$ytEventObj->transitionEvent($authToken, $youtubeEventId, $broadcastStatus); // $broadcastStatus = ["complete"]
<?php
namespace Your\App\NameSpace;
use trunks07\YoutubeLaravelApi\ChannelService;
NOTE: This doesn't require authorization token/**
* [channelsListById -gets the channnel details and ]
* $part 'id,snippet,contentDetails,status, statistics, contentOwnerDetails, brandingSettings'
* $params [array channels id(comma separated ids ) or you can get ('forUsername' => 'GoogleDevelopers')]
*/
$part = 'id,snippet';
$params = array('id'=> 'channel_1_id,channel_2_id');
$channelServiceObject = new ChannelService;
$channelDetails = $channelServiceObject->channelsListById($part, $params);
$channelServiceObject = new ChannelService;
$channelDetails = $channelServiceObject->getChannelDetails($authToken);
/*
* $params array('channel_id'=>'',
* 'max_results'= 10)
*/
$channelServiceObject = new ChannelService;
$channelDetails = $channelServiceObject->subscriptionByChannelId($params);
/*
* properties array('snippet.resourceId.kind' => 'youtube#channel','snippet.resourceId.channelId' => 'UCqIOaYtQak4-FD2-yI7hFkw')
*/
$channelServiceObject = new ChannelService;
$response = $channelServiceObject->addSubscriptions($properties, $token, $part='snippet', $params=[]);
-Remove Subscriptions For Authorized Channel To remove subscription we need subscription id which can be found from subscription list.
$response = $channelServiceObject->removeSubscription( $token, $subscriptionId);
/*
* $properties array('id' => '',
* 'brandingSettings.channel.description' => '',
* 'brandingSettings.channel.keywords' => '',
* 'brandingSettings.channel.defaultLanguage' => '',
* 'brandingSettings.channel.defaultTab' => '',
* 'brandingSettings.channel.moderateComments' => '',
* 'brandingSettings.channel.showRelatedChannels' => '',
* 'brandingSettings.channel.showBrowseView' => '',
* 'brandingSettings.channel.featuredChannelsTitle' => '',
* 'brandingSettings.channel.featuredChannelsUrls[]' => '',
* 'brandingSettings.channel.unsubscribedTrailer' => '')
*/
$channelServiceObject = new ChannelService;
$response = $channelServiceObject->updateChannelBrandingSettings($googleToken, $properties);
<?php
namespace Your\App\NameSpace;
use trunks07\YoutubeLaravelApi\VideoService;
$part ='snippet,contentDetails,id,statistics';
$params =array('id'=>'xyzgh');
$videoServiceObject = new VideoService;
$response = $videoServiceObject->videosListById($part, $params);
/*
* $videoPath path to the video
* $data array('title'=>"",
* 'description'=>"",
* 'tags'=>"",
* 'category_id'=>"",
* 'video_status'=>"")
*/
$videoServiceObject = new VideoService;
$response = $videoServiceObject->uploadVideo($googleToken, $videoPath, $data);
$videoServiceObject = new VideoService;
$response = $videoServiceObject->deleteVideo($googleToken, $videoId);
# rating 'like' or 'dislike' or 'none'
$videoServiceObject = new VideoService;
$response = $videoServiceObject->videosRate($googleToken, $videoId, $rating);
FAQs
It is a wrapper over Youtube Api v3 which simplifies functionalities the laravel way.
We found that trunks07/youtube-laravel-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.

Product
/Security News
Socket Calm is a free, open source syntax highlighting theme for VS Code, Vim, and Neovim, inspired by Socket's design system.

Product
Fix critical RubyGems vulnerabilities without upgrading dependencies. Free security patches are now available with more ways to install and deploy them.

Threat Research
/Security News
Socket researchers uncovered 13 malicious NuGet packages linked to fake developer job assessments, DLL side-loading, credential theft, and GitHub-based malware.