{"id":15561162,"url":"https://github.com/bahaaalhagar/youtube-uploader","last_synced_at":"2025-04-23T21:49:40.760Z","repository":{"id":62491235,"uuid":"143034019","full_name":"BahaaAlhagar/Youtube-Uploader","owner":"BahaaAlhagar","description":"PHP Laravel simple package to integrate with Youtube API","archived":false,"fork":false,"pushed_at":"2018-08-27T16:54:16.000Z","size":43,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-23T21:49:24.618Z","etag":null,"topics":["google-api","laravel","laravel-5-package","laravel-framework","php","uploader","youtube","youtube-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BahaaAlhagar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-31T15:36:21.000Z","updated_at":"2022-10-06T18:59:47.000Z","dependencies_parsed_at":"2022-11-02T09:31:30.811Z","dependency_job_id":null,"html_url":"https://github.com/BahaaAlhagar/Youtube-Uploader","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BahaaAlhagar%2FYoutube-Uploader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BahaaAlhagar%2FYoutube-Uploader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BahaaAlhagar%2FYoutube-Uploader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BahaaAlhagar%2FYoutube-Uploader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BahaaAlhagar","download_url":"https://codeload.github.com/BahaaAlhagar/Youtube-Uploader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522294,"owners_count":21444510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-api","laravel","laravel-5-package","laravel-framework","php","uploader","youtube","youtube-api"],"created_at":"2024-10-02T16:05:48.957Z","updated_at":"2025-04-23T21:49:40.743Z","avatar_url":"https://github.com/BahaaAlhagar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel 5 - YouTube Video Upload\n\n**Please note, that this package will only work with a single YouTube account and does not support multiple accounts.**\n\n## Installation\n\nTo install, use the following to pull the package in via Composer.\n\n```\ncomposer require bahaaalhagar/youtube-uploader\n```\n\nNow register the Service provider in `config/app.php`\n\n```php\n'providers' =\u003e [\n    ...\n    BahaaAlhagar\\YoutubeUploader\\YoutubeUploaderServiceProvider::class,\n],\n```\n\nAnd also add the alias to the same file.\n\n```php\n'aliases' =\u003e [\n    ...\n    'YoutubeUploader' =\u003e BahaaAlhagar\\YoutubeUploader\\Facades\\YoutubeUploader::class,\n],\n```\n\n## Configuration\n\nYou now need to publish the `youtubeUploader.php` config and migrations.\n\n```\nphp artisan vendor:publish --provider=\"BahaaAlhagar\\YoutubeUploader\\YoutubeUploaderServiceProvider\"\n```\n\nNow you'll want to run `php artisan migrate` to create the `youtube_access_tokens` table which as you would imagine, will contain your access tokens once you're authenticated correctly.\n\n### Obtaining your Credentials\n\nIf you haven't already, you'll need to create an application on [Google's Developer Console](https://console.developers.google.com/project). You then need to head into **Credentials** within the Console to create Server key.\n\nYou will be asked to enter your Authorised redirect URIs. When installing this package, the default redirect URI is `http://laravel.dev/youtube/callback`. Of course, replacing the domain (`laravel.dev`) with your applications domain name.\n\n**You can add multiple redirect URIs, for example you may want to add the URIs for your local, staging and production servers.**\n\nOnce you are happy with everything, create the credentials and you will be provided with a **Client ID** and **Client Secret**. These now need to be added to your `.env` file.\n\n```\nGOOGLE_CLIENT_ID=YOUR_CLIENT_ID\nGOOGLE_CLIENT_SECRET=YOUR_SECRET\n```\n\n### Authentication\n\nFor security reasons, the routes to authorize your channel with your Laravel application for disabled by default. You will need to enable them in your `config/youtube.php` before doing the following.\n\nNow your application is configured, we'll go through the inital authentication with Google. By default, the authorization route is `/youtube/auth`. Simply visit this URI in your application and you will be redirect to Google to authenticate your YouTube account.\n\nAssuming you were not presented with any errors during authentication, you will be redirected back to your application root. (`/`).\n\n### Reviewing your Token\n\nPreviously, users of this package have reported issues with their access token(s). To ensure you have the correct token, you simply need to review the `youtube_access_tokens` table you migrated earlier and review the value in the `access_token` column.\n\n**You need to check that a `refresh_token` exists within this value. If this is correct, you're all set to begin uploading.**\n\nYou will also want to disable the routes used for authorization as they will no longer be required since you are now autheticated. The token you just reviewed, assuming as a `refresh_token` will automatically be handled. \n\n# Upload a Video\n\nTo upload a video, you simply need to pass the **full** path to your video you wish to upload and specify your video information.\n\nHere's an example:\n\n```php\n$video = YoutubeUploader::upload($fullPathToVideo, [\n    'title'       =\u003e 'My Awesome Video',\n    'description' =\u003e 'You can also specify your video description here.',\n    'tags'\t      =\u003e ['foo', 'bar', 'baz'],\n    'category_id' =\u003e 10\n]);\n\nreturn $video-\u003egetVideoId();\n```\n\nThe above will return the ID of the uploaded video to YouTube. (*i.e dQw4w9WgXcQ*)\n\nBy default, video uploads are public. If you would like to change the privacy of the upload, you can do so by passing a third parameter to the upload method.\n\nFor example, the below will upload the video as `unlisted`.\n\n```php\n$video = YoutubeUploader::upload($fullPathToVideo, $params, 'unlisted');\n```\n\n### Custom Thumbnail\n\nIf you would like to set a custom thumbnail for for upload, you can use the `withThumbnail()` method via chaining.\n\n```php\n$fullpathToImage = storage_path('app/public/thumbnail.jpg');\n\n$video = YoutubeUploader::upload($fullPathToVideo, $params)-\u003ewithThumbnail($fullpathToImage);\n\nreturn $youtube-\u003egetThumbnailUrl();\n```\n\n**Please note, the maxiumum filesize for the thumbnail is 2MB**. Setting a thumbnail will not work if you attempt to use a thumbnail that exceeds this size.\n\n# Updating a Video\n\nTo update a video, you simply need to pass the **videoId** of the video you wish to update and specify your video information.\n\nHere's an example:\n\n```php\n$video = YoutubeUploader::update($videoId, [\n    'title'       =\u003e 'My Awesome Video',\n    'description' =\u003e 'You can also specify your video description here.',\n    'tags'\t      =\u003e ['foo', 'bar', 'baz'],\n    'category_id' =\u003e 10\n], $privacy);\n\nreturn $video-\u003egetVideoId();\n```\n\nNote: This request is explicit. Any params left out of the request will be removed.\n\n# Deleting a Video\n\nIf you would like to delete a video, which of course is uploaded to your authorized channel, you will also have the ability to delete it:\n\n```php\nYoutubeUploader::delete($videoId);\n```\n\nWhen deleting a video, it will check if exists before attempting to delete.\n\n\n# Create a Playlist\n\nTo create a playlist you must provide Playlist title and description.\n\nHere's an example:\n\n```php\n$playlist = YoutubeUploader::createPlaylist($title, $description);\n\nreturn $playlist-\u003egetPlaylistId();\n```\n\nThe above will return the ID of the created playlist on YouTube. (*i.e PLFgquLnL59akxkuW7czf5TvyjzcUMgaci*)\n\nBy default, playlists are public. If you would like to change the privacy of the playlist, you can do so by passing a third parameter to the createPlaylist method.\n\nFor example, the below will create the playlist as `unlisted`.\n\n```php\n$playlist = YoutubeUploader::createPlaylist($title, $description, 'unlisted');\n```\n\n# Add video to a Playlist\n\nIf you want to add a video to a playlist you have to provide the uploaded video id and the playlist id.\n\nHere's an example:\n\n```php\nYoutubeUploader::addVideoToPlaylist([\n\t'id' =\u003e 'jq498asd' // a youtube video id\n], $playlistId);\n```\n\nthis will return playlist Item Response.\n\nYou may also provide another title for video in playlist:\n\n```php\nYoutubeUploader::addVideoToPlaylist([\n\t'id' =\u003e 'jq498asd', // a youtube video id\n\t'title' =\u003e 'a new title for video in playlist'\n], $playlistId);\n```\n\nYou may also create the playlist and add video to it.\n\n```php\n$playlist = YoutubeUploader::createPlaylist($title, $description)-\u003eaddVideoToPlaylist([\n\t'id' =\u003e 'jq498asd', // a youtube video id\n]);\n```\n\n# Questions\n\nShould you have any questions, please feel free to submit an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahaaalhagar%2Fyoutube-uploader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahaaalhagar%2Fyoutube-uploader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahaaalhagar%2Fyoutube-uploader/lists"}