Laravel 5.5 – Social Auto Posting By toolkito/larasap
In this post we will give you information about Laravel 5.5 – Social Auto Posting By toolkito/larasap. Hear we will give you detail about Laravel 5.5 – Social Auto Posting By toolkito/larasapAnd how to use it also give you demo for it if it is necessary.
Today, we are sharing with you how to post text or midea(videos) in social portal. like facebook, twitter and telegram. we are finding one awesome laravel package for this you can do this things by toolkito/larasap
This is a Laravel package to post your content to social networks such:
- Telegram Channel (Based on Telegram Bot API)
Features:
- Simple. Easy to use.
- Send text message to Telegram channel
- Send photo to Telegram channel
- Send audio to Telegram channel
- Send document to Telegram channel
- Send video to Telegram channel
- Send voice to Telegram channel
- Send a group of photos or videos as an album to Telegram channel
- Send location to Telegram
- Send venue to Telegram
- Send contact to Telegram
- Send message with url inline keyboard to Telegram channel
- Send text and media to Twitter
- Send text and media to Facebook
Step : 1 Install Required Packages
First, we are install toolkito/larasap package in our laravel application using following command.
composer require toolkito/larasap
After successfully install package then Run the command below to publish the package config file: configlarasap.php
php artisan vendor:publish --tag=larasap
After run this command configlarasap.php file automatic generated, then open it and configer your required api token and keys. this file look like this.
return [ 'telegram' => [ 'api_token' => '', 'bot_username' => '', 'channel_username' => '', // Channel username to send message 'channel_signature' => '' // This will be assigned in the footer of message ], 'twitter' => [ 'consurmer_key' => '', 'consurmer_secret' => '', 'access_token' => '', 'access_token_secret' => '' ], 'facebook' => [ 'app_id' => '', 'app_secret' => '', 'default_graph_version' => '', 'page_access_token' => '' ] ];
Step : 2 Add Following Routes
Next, we are write following route in routes/web.php file.
// Send text message to Telegram Route Route::get('send-text-message-to-telegram', 'SocialSharingController@sendTextMessageToTelegram'); // Send photo to Telegram Route Route::get('send-photo-to-telegram', 'SocialSharingController@sendPhotoToTelegram'); // Send audio to Telegram Route Route::get('send-audio-to-telegram', 'SocialSharingController@sendAudioToTelegram'); // Send document to Telegram Route Route::get('send-document-to-telegram', 'SocialSharingController@sendDocumentToTelegram'); // Send video to Telegram Route Route::get('send-video-to-telegram', 'SocialSharingController@sendVideoToTelegram'); // Send voice to Telegram Route Route::get('send-voice-to-telegram', 'SocialSharingController@sendVoiceToTelegram'); // Send media group to Telegram Route Route::get('send-media-group-to-telegram', 'SocialSharingController@sendMediaGroupToTelegram'); // Send point on the map to Telegram Route Route::get('send-point-on-the-map-to-telegram', 'SocialSharingController@sendPointOnTheMapToTelegram'); // Send information about a venue to Telegram Route Route::get('send-information-about-a-venue-to-telegram', 'SocialSharingController@sendInformationAboutVenueToTelegram'); // Send message with inline button to Telegram Route Route::get('send-message-with-inline-button-to-telegram', 'SocialSharingController@sendMessageWithInlineButtonToTelegram'); // Send text tweet Route Route::get('send-text-tweet', 'SocialSharingController@sendTextTweet'); // Send tweet with media Route Route::get('send-tweet-with-media', 'SocialSharingController@sendTweetWithMedia'); // Send link to Facebook Route Route::get('send-link-to-facebook', 'SocialSharingController@sendLinkToFacebook'); // Send photo to Facebook Route Route::get('send-photo-to-facebook', 'SocialSharingController@sendPhotoToFacebook'); // Send video to Facebook Route Route::get('send-video-to-facebook', 'SocialSharingController@sendVideoToFacebook');
Step : 3 Create SocialSharingController.php File
Now, we are create SocialSharingController.php file in app/Http/Controllers folder. and add following sample .
namespace AppHttpControllers; use IlluminateHttpRequest; use ToolkitoLarasapSendTo; class SocialSharingController extends Controller { /** * Function For Telegram */ public function sendTextMessageToTelegram() { SendTo::Telegram('Hello, This is testing Laravel social auto posting'); dd('Youe message send successfully!!'); } public function sendPhotoToTelegram() { SendTo::Telegram( 'Hello, Im testing Laravel social auto posting', // Photo caption (Optional) [ 'type' => 'photo', // Message type (Required) 'file' => 'https://i.imgur.com/j6bzKQc.jpg' // Image url (Required) ], '' // Inline keyboard (Optional) ); dd('Youe message send successfully!!'); } public function sendAudioToTelegram() { SendTo::Telegram( 'Hello, Im testing Laravel social auto posting', // Audio caption (Optional) [ 'type' => 'audio', // Message type (Required) 'file' => 'http://example.com/let-me-be-your-lover.mp3', // Audio url (Required) 'duration' => 208, // Duration of the audio in seconds (Optional) 'performer' => 'Enrique Iglesias', // Performer (Optional) 'title' => 'Let Me Be Your Lover' // Track name (Optional) ], '' // Inline keyboard (Optional) ); dd('Youe message send successfully!!'); } public function sendDocumentToTelegram() { SendTo::Telegram( 'Hello, Im testing Laravel social auto posting', // Document caption [ 'type' => 'document', // Message type (Required) 'file' => 'http://example.com/larasap.pdf', // Document url (Required) ], '' // Inline keyboard (Optional) ); dd('Youe message send successfully!!'); } public function sendVideoToTelegram() { SendTo::Telegram( 'Hello, Im testing Laravel social auto posting', // Video caption (Optional) [ 'type' => 'video', // Message type (Required) 'file' => 'http://example.com/let-me-be-your-lover.mp4', // Audio url (Required) 'duration' => 273, // Duration of sent video in seconds (Optional) 'width' => 1920, // Video width (Optional) 'height' => 1080 // Video height (Optional) ], '' // Inline keyboard (Optional) ); dd('Youe message send successfully!!'); } public function sendVoiceToTelegram() { SendTo::Telegram( 'Hello, Im testing Laravel social auto posting', // Voice message caption (Optional) [ 'type' => 'voice', // Message type (Required) 'file' => 'https://upload.wikimedia.org/wikipedia/en/9/9f/Sample_of_%22Another_Day_in_Paradise%22.ogg', // Audio url (Required) 'duration' => 28 // Duration of the voice message in seconds (Optional) ], '' // Inline keyboard (Optional) ); dd('Youe message send successfully!!'); } public function sendMediaGroupToTelegram() { SendTo::Telegram( null, [ 'type' => 'media_group', // Message type (Required) 'files' => // Array describing photos and videos to be sent, must include 2–10 items [ [ 'type' => 'photo', // Media type (Required) 'media' => 'https://i.imgur.com/j6bzKQc.jpg', // Media url (Required) 'caption' => 'Laravel sccial auto posting' // Media caption (Optional) ], [ 'type' => 'video', // Media type (Required) 'media' => 'http://example.com/let-me-be-your-lover.mp4', // Media url (Required) 'caption' => 'Let me be your lover' // Media caption (Optional) ] ] ] ); dd('Youe message send successfully!!'); } public function sendPointOnTheMapToTelegram() { SendTo::Telegram( null, [ 'type' => 'location', // Message type (Required) 'latitude' => 36.1664345, // Latitude of the location (Required) 'longitude' => 58.8209904, // Longitude of the location (Required) 'live_period' => 86400, // Period in seconds for which the location will be updated (Optional) '' // Inline keyboard (Optional) ); dd('Youe message send successfully!!'); } public function sendInformationAboutVenueToTelegram() { SendTo::Telegram( null, [ 'type' => 'venue', // Message type (Required) 'latitude' => 36.166048, // Latitude of the location (Required) 'longitude' => 58.822121, // Longitude of the location (Required) 'title' => 'Khayyam', // Name of the venue (Required) 'address' => 'Neyshabur, Razavi Khorasan Province, Iran', // Address of the venue (Required) 'foursquare_id' => '', // Foursquare identifier of the venue (Optional) '' // Inline keyboard (Optional) ); dd('Youe message send successfully!!'); } public function sendMessageWithInlineButtonToTelegram() { SendTo::Telegram( 'Laravel social auto posting', '', [ [ [ 'text' => 'Github', 'url' => 'https://github.com/toolkito/laravel-social-auto-posting' ] ], [ [ 'text' => 'Download', 'url' => 'https://github.com/toolkito/laravel-social-auto-posting/archive/master.zip' ], ] ] ); // OR SendTo::Telegram( 'Laravel social auto posting', '', [ [ [ 'text' => 'Github', 'url' => 'https://github.com/toolkito/laravel-social-auto-posting' ], [ 'text' => 'Download', 'url' => 'https://github.com/toolkito/laravel-social-auto-posting/archive/master.zip' ], ] ] ); dd('Youe message send successfully!!'); } /** * Function For Twitter */ public function sendTextTweet() { SendTo::Twitter('Hello, Im testing Laravel social auto posting'); dd('Youe message send successfully!!'); } public function sendTweetWithMedia() { SendTo::Twitter( 'Hello, Im testing Laravel social auto posting', [ public_path('photo-1.jpg'), public_path('photo-2.jpg') ] ); dd('Youe message send successfully!!'); } /** * Function For Facebook */ public function sendLinkToFacebook() { SendTo::Facebook( 'link', [ 'link' => 'https://github.com/toolkito/laravel-social-auto-posting', 'message' => 'Laravel social auto posting' ] ); dd('Youe message send successfully!!'); } public function sendPhotoToFacebook() { SendTo::Facebook( 'photo', [ 'photo' => public_path('img/1.jpg'), 'message' => 'Laravel social auto posting' ] ); dd('Youe message send successfully!!'); } public function sendVideoToFacebook() { SendTo::Facebook( 'video', [ 'video' => public_path('upload/1.mp4'), 'title' => 'Let Me Be Your Lover', 'description' => 'Let Me Be Your Lover - Enrique Iglesias' ] ); dd('Youe message send successfully!!'); } }
Now we are ready to run our example so run bellow command ro quick run:
php artisan serve
Now you can test one by one route url in your browser like that:
http://localhost:8000/send-text-tweet
We are hope you like this tutorials, if any question regarding any query please post your question in our forums click on bellow link Laravel’s Forums
Hope this and post will helped you for implement Laravel 5.5 – Social Auto Posting By toolkito/larasap. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs