Posted on Leave a comment

#TwitterGate Twitter Was Hacked 400M Users Compromised!

#TwitterGate Is Currently Going DOWN!

Things are not looking good for Elon Musk and haven’t been since day one. It has come to the public’s attention that Twitter was hacked and 400M, yes that’s 400 HUNDRED MILLION users’ data has been compromised. This is Jyrone Parker, if you are new to this channel I make tech talk videos and coding live streams, and today I am exploring #TwitterGate the biggest Twitter hack in existence.

It hasn’t even been a full two months yet and Elon’s dream of a Twitter empire is crashing down. Maybe that’s why he has decided to step down as CEO as soon as he *ahem* finds someone foolish enough to take the job. So what’s going on with this hack? Well, apparently some threat actor who goes by Ryushi has claimed that a hacker group has a dataset for sale that contains over 400 million Twitter user’s data including email addresses, and phone numbers, these include accounts such as AOC, Brian Krebbs, and Vitalik Buterin. What’s even worse is that they are demanding a ransom from Elon Musk for an unspecified price, many Twitter users are urging him to pay it (me I’m not so sure). In addition to this, the Irish Data Protection Commission announced in light of these revelations they will be doing an investigation into Twitter’s data practices.

#TwitterGate is in full effect!

Protect Your Accounts NOW!

What can you do to protect yourself from the #TwitterGate hack? First off change your password! Enable 2FA and use a throwaway email account and/or phone number. Not just your Twitter password but all of them. Most people reuse passwords and if you are one of those people your other social media accounts are also at risk.

Even though for the majority of users this won’t be a huge deal but for the sake of security you need to protect your accounts. If you have any questions or comments please feel free to leave them in the comments below. Also please support the site by visiting the shop it goes a long way in keeping this blog going! Don’t forget to follow me on Twitter and Instagram!

Posted on Leave a comment

How To Prepare for a Successful Entrepreneurial Journey

a man glancing out the airplane window

How To Prepare for a Successful Entrepreneurial Journey

So you want to be your own boss? Great! Making the leap into entrepreneurship is an exciting and rewarding process. But it’s not without its challenges. 

Fortunately, there are a few things you can do to set yourself up for success. In this blog post, Jyrone Parker shares six tips for preparing to become an entrepreneur. From getting an online degree to funding your business, these strategies will put you on the path to greatness:

1. Get an Online Degree To Sharpen Your Business Skills

If you’re serious about becoming a successful entrepreneur, consider getting an online degree in business or a related field. Many accredited online programs can help you gain the skills and knowledge you need to run a successful business. Not to mention, having a degree can make you more attractive to potential investors and customers. 

With today’s technology, there’s no excuse not to take advantage of online education opportunities. When looking at the options, only consider accredited universities with tuition rates you can afford. Studying online will strengthen your business acumen without hindering you from your job or family commitments. 

2. Learn About the Different Business Structures 

There are several different business structures you can choose from when starting your own company. These include sole proprietorships, partnerships, limited liability companies (LLCs), and corporations. It’s important to learn about the pros and cons of each structure so you can choose the option that makes the most sense for your particular business.

Many entrepreneurs form LLCs because it protects them from personal liability for the debts and obligations of the company. This can prove invaluable if your company is sued or goes bankrupt. Also, you can choose how the company is taxed and take advantage of certain tax deductions and credits. Research the LLC rules in your state, and hire a formation service to do the heavy lifting. 

3. How To Create a Productive Work Space or Find an Office Space  

One of the challenges of working from home is creating a productive work environment. It can be tempting to lounge in your PJs all day or take work calls from bed, but this isn’t conducive to a productive workday. Instead, try to create a dedicated workspace in your home, such as a spare bedroom or home office. 

If you struggle with distractions, you might want to find an office space outside of your home so you can separate your work life from your personal life. Spend time looking into your options, and ensure your office space is the size you need, especially if you plan on hiring employees. 

4. How To Get the Funding You Need  

Many aspiring entrepreneurs quit on their dreams because they don’t have the capital necessary to get their businesses off the ground. If this is something you battle, you have several options. You could apply for small business loans, look into venture capital firms, or launch a crowdfunding campaign. Do some research and see which options make the most sense for your business. 

5. Types of Tech Tools That Can Help  

Technology has come a long way in recent years, and many different tech tools are available to help entrepreneurs run their businesses more efficiently. Some examples include project management, invoicing, customer relationship management (CRM), and accounting software. Take time to research the wealth of tech tools on the market that can streamline your operations. 

6. How To Create a Routine and Schedule  

One of the benefits of being your own boss is having flexibility with your schedule. However, this can also be a challenge. Without set office hours, it’s easy to let work consume your entire day—and night! To avoid burnout, you must set some parameters around when and how often you’ll work each day, week, and month.  

Conclusion

Congratulations—you’re on your way to becoming an entrepreneur! Keep these tips in mind as you prepare for this exciting journey, and with some hard work and dedication, you’ll be running your own successful business in no time. Just remember to believe in yourself and stay true to your core values, and you’ll maintain the motivation necessary to thrive. 

If you like this content, check out my startup MobiSnacks available for iOS and Android!

Posted on 1 Comment

Should All Professionals Learn How to Code?

Will coding be seen as a necessity in the future?



These days, most people are interested in learning how to code. As more and more of our daily and work life functions involve technologies, understanding the principles of coding languages is crucial — and the demand for computer science education reflects that. Market research from Technavio found that the global coding boot camp market size is expected to grow by $1.20 billion by 2026. This increase in student enrollment is attributed to the low cost and shorter duration of boot camp training, especially compared to formal education alternatives.

In fact, some employers have foregone relevant bachelor’s degree requirements for roles that require coding knowledge. People are also learning how to code at earlier age groups by having kids create VR games on the Babylon.js framework, for example. As coding training and education become more and more accessible, industry professionals who have never considered it an option may be pressured to try and learn — but should they?

Today, we’ll explore some of the reasons coding training may be essential for all professionals:

No-code and low-code still need coding knowledge



In a time of global digital talent scarcity, businesses have adapted by using no-code and low-code platforms to allow for AI application developments — even from employees who aren’t technically qualified. According to insights on AI democratization from Fortune, aside from making complex technologies more accessible, businesses also benefit by the ability to develop algorithms faster using these platforms and do so at lower costs. However, while offering convenience, no-code and low-code platforms and tools still require solid knowledge of principles and relevant data to be used successfully. Employees tasked with using these platforms should also be aware of their associated risks.

Coding prepares us for the future of work



As digital technologies continue to develop and evolve, businesses across industries will want to adopt the latest technologies and the most qualified talent to gain a competitive advantage in the market. Recently, LHH published Dick Verburg’s insights on learning, where he highlighted how only 9% of human resource officers feel their workforce is actually prepared for the future of work. Verburg emphasizes the importance of businesses shifting away from “buying” talent towards “building” on the existing workforce instead through initiatives and approaches to employee learning. Companies that invest in training their employees how to code may find new roles for this talent which can elevate existing business processes.

Coding is everywhere



While industry professionals may be hesitant to pursue coding training or education because it is outside their field or career path, it isn’t easy to be sure of that these days. As the technologies continue to evolve and create new data that call for new automation and processes, coding knowledge and expertise will continue to be required, making applications that are easier to use available for consumers. Supermodel and entrepreneur Karlie Kloss’ feature on coding and the future of fashion is an example of coding expertise seeing value in markets outside of big tech and Silicon Valley, and fashion is only one among many industries that will rely more and more on technologies. Kloss also highlights another practical benefit of learning to code, that is, to develop strong problem-solving skills.

While skipping out on learning how to code may not harm your existing work or career, you might just open doorways to new and exciting opportunities in the future if you take the time to learn even the basic principles of it, or face a realm of possibilities if you choose to pursue coding deeper.

Posted on Leave a comment

Tech Upgrades to Boost Business Productivity and Save Money

Tech Upgrades to Boost Business Productivity and Save Money

Taking advantage of modern technology is important for keeping your business competitive. However, many business owners are hesitant to spend money on the latest tech. What if your investment doesn’t pay off? As a small business owner, you can’t afford to waste capital on fancy new tools and equipment just for the sake of being innovative. Your tech investments need to save you enough money that they pay for themselves in the long run. 

The good news is that there are several tools out there that can do just that! You just have to know where to look—and how to pick the right technology for your unique business needs. Are you ready to invest in some new technology and take your business to the next level? Here are a few tools that are bound to pay off!

Project Management Software

Project management tools can make your life a lot easier. Even if you have a small team, good project management software will help you stay on schedule, optimize the use of your available resources, and monitor progress from one centralized platform. This will save you the headache of constant back-and-forth emails and enable your team to get work done more quickly. Look for project management software that allows you to collaborate in real-time with your team members. 

Meeting Scheduling Platforms

Scheduling meetings with team members and clients is another common business task that can take a lot of unnecessary time. How many emails do you have to send before you land at a meeting time that works for everyone? According to Boomerang, it takes an average of 8 emails to schedule a single meeting! Instead, take advantage of meeting scheduling apps and tools. For example, Calendly lets people schedule meetings based on their availability, which is ideal for business owners who get a lot of meeting requests.

Accounting Apps

Accounting is yet another one of those administrative tasks that take a lot of time. And when you don’t know what you’re doing, accounting mistakes can wind up costing a lot of money! Take advantage of accounting software to save time and keep more money in your business. With accounting software for your SMB, you will be able to automate a lot of your accounting processes so you can spend less time calculating taxes and more time focusing on big-picture projects. You’ll also be able to track expenses and inventory and send electronic invoices to get paid faster.

Email Marketing Software

If you collect emails from your customers—and you should—email marketing software will help you extract the most value out of your list. Email marketing tools make it easy to store, organize, and segment your audience so you can promote your business more effectively. At the same time, you’ll be able to use your email tools to schedule automatic abandoned cart emails and drip campaigns to improve your customer conversions!

Social Media Scheduling Tools

Posting on social media and engaging with your followers is one of the most affordable ways to advertise your business. But staying on top of your social media marketing tasks can be challenging. Thankfully, there are many social media management tools that allow you to create and schedule posts in advance. These social tools also make it easier for team members to respond to customers on social media from one easy-to-use platform.

The right technology can make your small business much more productive. Tech tools will help you automate time-consuming tasks, avoid common human errors, manage your finances, and save money across all areas of your business. Start exploring small business tech tools today so you can catch up with your competitors!

Work with software entrepreneur Jyrone Parker to take your business to the next level!

Posted on 1 Comment

Upgrading The Discord Twitter Bot To Use The Twitter V2 API

close up photo of toy bot

Twitter Upgraded Their API & Broke My Bot!!

Imagine my frustration when I get dozens of DMs, emails, and other messages asking when I was going to upgrade my Discord Twitter bot to be compliant with the latest Twitter changes. Like damn bro, I have other things to do lol but alas I can’t let my peeps down. In this blog entry, I will show you what I did to upgrade my codebase to use the Twitter V2 API to communicate with the Discord server to send out my tweets.

Twitter has been an integral part of social media and has become a platform for information exchange, news updates, and social interactions. Twitter offers an API that allows developers to create applications that can interact with Twitter data. Recently, Twitter introduced a new version of its API called the Twitter V2 API, which includes several updates and improvements. One of the notable features of the Twitter V2 API is the Rules API, which enables developers to create complex filters and rules for retrieving Tweets and other Twitter data.

v2 of the Discord Twitter bot

Upgrading The Package.json File

We are no longer using the Twit npm package and instead using the twitter-v2 npm package. Open your package.json file and change it to the following:

{
  "name": "discord-twitter-bot",
  "version": "2.0.0",
  "description": "A discord bot that sends messages to a channel whenever a specific user tweets.",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/mastashake08/discord-twitter-bot.git"
  },
  "keywords": [
    "discord",
    "twitter",
    "bot"
  ],
  "author": "mastashake08",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/mastashake08/discord-twitter-bot/issues"
  },
  "homepage": "https://github.com/mastashake08/discord-twitter-bot#readme",
  "dependencies": {
    "discord.js": "^13.8.1",
    "dotenv": "^8.2.0",
    "twitter-v2": "^1.1.0"
  },
  "engines" : {
    "npm" : ">=7.0.0",
    "node" : ">=16.0.0"
  }
}

Listen To Some Hacker Music While You Code

Follow me on Spotify I make Tech Trap music

Changes To The Twitter API

In order to use the stream API, we have to set up stream rules. We want to only show tweets from yourself so in your .env file add a new field

TWITTER_USER_NAME=

Afterward, we listen to the stream pretty much as before. Open up the main.js file and update it to the following.

require('dotenv').config()
const Twit = require('twitter-v2')
const { Client } = require('discord.js');
const client = new Client({ intents: 2048 });


var T = new Twit({
  // consumer_key:         process.env.TWITTER_CONSUMER_KEY,
  // consumer_secret:      process.env.TWITTER_CONSUMER_SECRET,
  // access_token_key:         process.env.TWITTER_ACCESS_TOKEN,
  // access_token_secret:  process.env.TWITTER_ACCESS_TOKEN_SECRET,
  // timeout_ms:           60*1000,  // optional HTTP request timeout to apply to all requests.
  // strictSSL:            true,     // optional - requires SSL certificates to be valid.
  bearer_token:  process.env.BEARER_TOKEN
})

//   //only show owner tweets
async function sendMessage (tweet, client){
  console.log(tweet)
  const url = "https://twitter.com/user/status/" + tweet.id;
  try {
    const channel = await client.channels.fetch(process.env.DISCORD_CHANNEL_ID)
    channel.send(`${process.env.CHANNEL_MESSAGE} ${url}`)
  } catch (error) {
        console.error(error);
  }
}

async function listenForever(streamFactory, dataConsumer) {
  try {
    for await (const { data } of streamFactory()) {
      dataConsumer(data);
    }
    // The stream has been closed by Twitter. It is usually safe to reconnect.
    console.log('Stream disconnected healthily. Reconnecting.');
    listenForever(streamFactory, dataConsumer);
  } catch (error) {
    // An error occurred so we reconnect to the stream. Note that we should
    // probably have retry logic here to prevent reconnection after a number of
    // closely timed failures (may indicate a problem that is not downstream).
    console.warn('Stream disconnected with error. Retrying.', error);
   // listenForever(streamFactory, dataConsumer);
  }
}

async function  setup () {
  const endpointParameters = {
      'tweet.fields': [ 'author_id', 'conversation_id' ],
      'expansions': [ 'author_id', 'referenced_tweets.id' ],
      'media.fields': [ 'url' ]
  }
  try {
    console.log('Setting up Twitter....')
    const body = {
      "add": [
        {"value": "from:"+ process.env.TWITTER_USER_NAME, "tag": "from Me!!"}
      ]
    }
   const r = await T.post("tweets/search/stream/rules", body);

  } catch (err) {
    console.log(err)
  }

  listenForever(
    () => T.stream('tweets/search/stream'),
    (data) => sendMessage(data, client)
  );
}
// Add above rule

client.login(process.env.DISCORD_TOKEN)
 client.on('ready', () => {
   console.log('Discord ready')
   setup()

 })

What is the Twitter V2 Rules API?

The Twitter V2 Rules API is a set of endpoints that allows developers to create, manage and delete rules for filtering and retrieving Twitter data. With the Rules API, developers can define specific criteria that must be met for a Tweet or a stream of Tweets to be returned. This means developers can create more sophisticated and complex search queries and filters than before.

The Twitter V2 Rules API provides a comprehensive set of operators that can be used to create rules. These operators include “contains,” “hashtag,” “from,” “to,” “mention,” “URL,” “geo,” “lang,” and “is.” With these operators, developers can create rules based on keywords, hashtags, location, language, and many other criteria.

How to use the Twitter V2 Rules API?

To use the Twitter V2 Rules API, developers need to create a Twitter Developer Account and obtain API keys and access tokens. Once the developer has the necessary credentials, they can use the Rules API to create and manage rules for filtering Twitter data.

To create a rule, developers can use the POST /2/tweets/search/stream/rules endpoint, which accepts a JSON payload containing the rule definition. For example, to create a rule that returns Tweets containing the hashtag “#apple” and “iPhone,” the following JSON payload can be used:

{
  "add": [
    {
      "value": "#apple iPhone",
      "tag": "apple-tweets"
    }
  ]
}

This payload contains the “add” operator, which adds a new rule to the stream. The “value” field contains the search query, and the “tag” field is an optional label that can be used to identify the rule.

Once the rule is added, developers can use the GET /2/tweets/search/stream endpoint to retrieve the stream of Tweets that match the defined rule.

Why use the Twitter V2 Rules API?

The Twitter V2 Rules API offers several benefits for developers. Firstly, it provides more powerful and sophisticated filtering capabilities, allowing developers to create more precise and targeted search queries. This is particularly useful for businesses and organizations that need to monitor Twitter for specific keywords, trends, or events.

Secondly, the Twitter V2 Rules API is more reliable and scalable than previous versions. It supports higher throughput and lower latency, making it easier to retrieve and process large volumes of Twitter data.

Lastly, the Twitter V2 Rules API provides better documentation and support, making it easier for developers to get started and integrate with Twitter. The API also includes features such as pagination and rate limiting, which help developers manage their usage and avoid hitting API limits.

The Twitter V2 Rules API is a powerful and flexible tool for developers who need to retrieve and filter Twitter data. With the Rules API, developers can create complex search queries and filters that enable them to access the specific data they need. This makes the API particularly useful for businesses, organizations, and researchers who need to monitor Twitter for specific keywords, trends, or events. If you are a developer looking to work with Twitter data, the Twitter V2 Rules API is definitely worth exploring.

Usage

Via Docker

docker run --env-file= -d --name= mastashake08/discord-twitter-bot:latest

By running this command you can pull the image directly from Docker Hub all you have to do is pass in a path to your .env file with your tokens.

Via Github Container Registry

docker pull ghcr.io/mastashake08/discord-twitter-bot:latest

If you rather use GCR then you can!

Via Node

If you decide to run from source then pull the repo, set the .env and run the code

 git clone https://github.com/mastashake08/discord-twitter-bot.git
 npm install
 cp .env.example .env
 #set values for TWITTER and DISCORD APIs in .env
 TWITTER_USER_NAME=
 DISCORD_TOKEN=
 DISCORD_CHANNEL_ID=
 BEARER_TOKEN=
 CHANNEL_MESSAGE= 
node main.js

Congrats, It’s Updated!

See it in action!

That’s pretty much all we had to do to update everything to use the new API. The added benefit is that it won’t show retweets in your discord server like before :0 if you enjoyed this consider becoming a patron on Patreon and help fund in-person coding classes for kids in Louisville, KY!

Follow Me On Social Media

Follow Me On Youtube!

Follow my YouTube account

Get Your Next Domain Cheap & Support The Channel

I use Namecheap for all of my domains! Whenever I need a cheap solution for a proof-of-concept project I grab a domain name for as little as $1! When you sign up and buy your first domain with Namecheap I get a commission, it’s a great way to get a quality service and support this platform!

Get Your Next Domain Cheap
CLICK HERE

Become A Sponsor

Open-source work is free to use but it is not free to develop. If you enjoy my content and would like to see more please consider becoming a sponsor on Github or Patreon! Not only do you support me but you are funding tech programs for at risk youth in Louisville, Kentucky.

Join The Newsletter

By joining the newsletter, you get first access to all of my blogs, events, and other brand-related content delivered directly to your inbox. It’s 100% free and you can opt out at any time!

Check The Shop

You can also consider visiting the official #CodeLife shop! I have my own clothing/accessory line for techies as well as courses designed by me covering a range of software engineering topics.

Posted on 1 Comment

Today I Began Teaching My Kids How To Code

Those of you who have been following my content creation journey since the beginning may remember my children being on my live streams.  They are finally learning how to code this summer by making video games! Follow us over the next couple of months as we make VR games using the Babylon.js framework.

Patrons get behind-the-scenes access to the source code and special content as I teach these two mini geniuses. I continue to thank you all who have supported me, the channel, and the kid coding community.

So what is Babylon.js? It is an amazing Javascript 3D video game framework that uses WebXR and WebGPU technologies to enable us to make web games for the Oculus Quest! Ethan and Moriah will be creating VR dinosaur and unicorn Oculus games this summer. I really hope that if you have kids or know of kids who want to code this summer please have them subscribe to my Youtube channel and check the channel Monday – Friday this summer and participate in the live stream! All you need is a code editor and a web browser!

I created a repository on Github for the adventures you can follow along at https://github.com/mastashake08/dinosaur-unicorn-babylon-vr please feel free to fork and see the daily code updates!

Posted on Leave a comment

Teaching Your Employees to Recognize and Avoid Common Internet Scams 

woman holding macbook

Teaching Your Employees to Recognize and Avoid Common Internet Scams

An informed workforce is your best defense against cyberattacks. Every time your employees go online, whether to check their email or conduct a search, they could encounter internet scams that put your business at risk. Cybercriminals like to target employees, especially those with access to sensitive financial information. Because your employees are your first line of defense against threats, you must empower them to protect your company!

Here are some tips presented by JyroneParker.com to help you teach your employees to avoid common cybersecurity threats. 

Start with a Recovery Plan

Every business needs a cybersecurity disaster recovery plan. Employee education and vigilance aren’t always enough to prevent cybercriminals from bypassing your defenses. Don’t wait for a disaster to happen to formulate a recovery plan! If your business experiences a cyber-attack, your recovery plan will enable you to get back up and running as quickly as possible so you can avoid angering your customers or disrupting your cash flow. When it comes to planning for potential cyber security threats, be sure to identify which data you will need to recover first in the event of an attack. This way, you’ll be able to put together a recovery plan that will help restore trust among your clients and customers.

Of course, creating a disaster recovery plan is no mean feat. With the level of detail, research, and strategizing that goes into it, you’ll definitely find your hands full. If you find yourself needing to reshuffle your work tasks to get this vital measure in place, you’ll need to find ways to organize your time differently. Download a planner template and use visual elements like sticky notes to keep you on track without taking much away from your other tasks.

Phishing Attacks

Phishing attacks are some of the most common internet scams. In a phishing scam, an attacker tricks their victim into clicking a link or downloading a file, resulting in any manner of damaging attacks. These attacks usually occur over email, but social media, instant messaging services, and apps are also frequently used in phishing attempts. Phishing emails often look like they’ve been sent by a company you know, so it’s important to know how to identify them.

Trojan Horse Software

Trojan horse software is a malicious program that appears legitimate but can take control of your computer after being downloaded. Trojans can do different things, from stealing sensitive information to freezing important data. Make sure your employees know not to click on pop-up windows, download programs from unknown publishers or click links in emails from people they don’t recognize. 

Tech Support Scams

The Federal Trade Commission explains that tech support scammers will lead you to believe that there’s something wrong with your computer and you will have to pay for tech support services to fix the issue. These scams often appear as pop-up warnings that look like error messages on your computer. Show your employees some examples of these scam attempts so they know what to look out for when working online.

Public Wi-Fi Scams

If your employees work remotely some or part of the time, make sure they know how to avoid public Wi-Fi scams. In public places, like coffee shops or airports, scammers may set up Wi-Fi networks with a name similar to one you would expect. Once you connect to this network, the hacker can steal your passwords, scan emails, or otherwise access your sensitive data. Discourage your employees from using public Wi-Fi for sensitive business tasks, like accessing business bank accounts or making purchases. You may also want to provide your employees with a VPN service to encrypt their connections and make public Wi-Fi safer.

Commit to Regular Cybersecurity Training

Teaching your employees how to avoid internet scams should be an ongoing process. Hackers are getting increasingly skilled and attacks are becoming more sophisticated by the day. Protect your business from these ever-evolving threats by committing to regular employee education. Make cybersecurity a common topic to address in team meetings so you can remind your employees how they can best protect themselves and your company from threats. Importantly, ensure your cybersecurity messages are understandable and relatable. You want your employees to feel responsible for their stake in your company’s security plan.

Cybersecurity is an important topic that’s often overlooked by small business owners. Even if you did everything in your power to shield your business from online threats, your employees still create points of vulnerability. Commit to cybersecurity training so your employees know how to reduce their risk of falling for internet scams.

Posted on Leave a comment

Adding Google Drive Functionality To Screen Recorder Pro

You All Requested Google Drive Functionality!

In my last YouTube video, I was asked to implement Google Drive upload functionality for saving screen recordings. I thought this was a marvelous idea and immediately got to work! We already added OAuth login via Google and Laravel in the last tutorial to interact with the Youtube Data v3 API, so with a few simple backend tweaks, we can add Google Drive as well!

Steps To Accomplish

The functionality I want to add to this is going to be just uploading to Google Drive, with no editing or listing. Keep things simple! This is going to require the following steps

  • Adding Google Drive scopes to Laravel Socialite
  • Create a function to upload file to Google API endpoint

Pretty easy if I do say so myself. Let’s get started with the backend.

Adding Google Drive Scopes To Laravel Socialite

We already added scopes for YouTube in the last tutorial so thankfully not a whole lot of work is needed to add Google Drive scopes. Open up your routes/api.php file and update the scopes array to include the new scopes needed to interact with Google Drive

Route::get('/login/youtube', function (Request $request) {
  return Socialite::driver('youtube')->scopes(['https://www.googleapis.com/auth/youtube', 'https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.metadata', 'https://www.googleapis.com/auth/drive.metadata.readonly'])->stateless()->redirect();
});

Make sure you enable the API in the Google cloud console! Now we head over to the frontend Vue application and let’s add our markup and functions.

Open the Home.vue and we are going to add a button in our list of actions for uploading to Google Drive

<t-button v-on:click="uploadToDrive" v-if="uploadReady" class="ml-10">Upload To Drive 🗄️</t-button>
    

In the methods add a function called uploadToDrive() inside put the following

  async uploadToDrive () {
      let metadata = {
          'name': 'Screen Recorder Pro - ' + new Date(), // Filename at Google Drive
          'mimeType': 'application/zip', // mimeType at Google Drive
      }
      let form = new FormData();
      form.append('metadata', new Blob([JSON.stringify(metadata)], {type: 'application/json'}));
      form.append('file', this.file);
      await fetch('https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart', {
        method: 'POST', // *GET, POST, PUT, DELETE, etc.
        mode: 'cors', // no-cors, *cors, same-origin
        cache: 'no-cache',
        headers: {
          'Content-Length': this.file.length,
          Authorization: `Bearer ${this.yt_token}`
        },
        body: form
      })
      alert('Video uploaded to Google Drive!')
    }

Inside this function we create an HTTP POST request to the Google Drive endpoint for uploading files. We pass a FormData object that contains some metadata about the object and the actual file itself. After the file is uploaded the user is alerted that their video is stored!

Screen Recorder Pro Google Drive upload confirmation

What’s Next?

Next, we will add cloud storage you will be able to share with Amazon S3 and WebShare API! Finally we will add monetization and this project will be wrapped up! If you enjoyed this please give the app a try at https://recorder.jcompsolu.com