<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Mahallawy </title>
    <description>The latest articles on Forem by Mahallawy  (@ahmed_mahallawy).</description>
    <link>https://forem.com/ahmed_mahallawy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F406861%2Ff4bc8d8d-c243-4db0-a963-e9cdb2a36edf.jpg</url>
      <title>Forem: Mahallawy </title>
      <link>https://forem.com/ahmed_mahallawy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ahmed_mahallawy"/>
    <language>en</language>
    <item>
      <title>Tweeting with an image using Node JS</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Sat, 10 Jul 2021 15:21:41 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/tweeting-with-an-image-using-node-js-2aie</link>
      <guid>https://forem.com/ahmed_mahallawy/tweeting-with-an-image-using-node-js-2aie</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;This is my fourth tutorial about using Twitter API with Node JS. My previous tutorials are listed up there 👆.&lt;/p&gt;

&lt;p&gt;In my first tutorial, I showed how to tweet with only text using Twitter API and Node JS, see &lt;a href="https://dev.to/ahmed_mahallawy/tweeting-using-node-js-5986"&gt;here&lt;/a&gt;.&lt;br&gt;
Then I got a question on how to tweet with an image, thanks to &lt;a class="mentioned-user" href="https://dev.to/thomasbnt"&gt;@thomasbnt&lt;/a&gt; and &lt;a class="mentioned-user" href="https://dev.to/generativexbot"&gt;@generativexbot&lt;/a&gt; , so here I'll explain my way to do this.&lt;/p&gt;
&lt;h3&gt;
  
  
  Before we start
&lt;/h3&gt;

&lt;p&gt;You need to have a Twitter Developer account and for the basic configurations please go &lt;a href="https://dev.to/ahmed_mahallawy/tweeting-using-node-js-5986"&gt;here&lt;/a&gt; for more explanation as I follow the same structure.&lt;/p&gt;
&lt;h3&gt;
  
  
  Let's start
&lt;/h3&gt;

&lt;p&gt;To tweet an image, the process will consist of two requests:&lt;br&gt;
1- Uploading the image&lt;br&gt;
2- Tweeting with that image&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The new thing here is that each request uses a different subdomain in the Twitter API url, which means that a small change will be done on the config.js file.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const twitter = require('twitter-lite');

exports.newClient = function (subdomain = 'api') {
    return new twitter({
        subdomain,
        consumer_key: '',
        consumer_secret: '',
        access_token_key: '',
        access_token_secret: ''
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Here I changed the configurations to be returned as a function instead of a JSON object. The function returns a twitter lite client that I moved its definition here for simplicity. The reason I did that is the new configuration attribute &lt;strong&gt;subdomain&lt;/strong&gt;, which can be set from the function parameter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-Now, we are ready to edit the index.js file. Some changes must be made after changing the config.js file:&lt;br&gt;
1- Remove twitter lite definition&lt;br&gt;
2- Define twitter lite clients for both subdomains to be used later&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const apiClient = config.newClient();
const uploadClient = config.newClient('upload');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I got this photo to be used with the tweet&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqawdp4gil1arcvj0iv4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqawdp4gil1arcvj0iv4.png" alt="hello_world.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then we deal with the image file and make it ready for the upload by defining the &lt;strong&gt;fs&lt;/strong&gt; and &lt;strong&gt;path&lt;/strong&gt; modules.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');
const path = require('path');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then, read the file as a 64 based file.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mediaFile = fs.readFileSync(path.join(__dirname, 'hello_world.png'));
const base64image = Buffer.from(mediaFile).toString('base64');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Next, it's similar to what we did in this &lt;a href="https://dev.to/ahmed_mahallawy/like-retweet-and-follow-in-twitter-using-node-js-5gbc"&gt;tutorial&lt;/a&gt; where a request is depending on the result of another request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The first request is for uploading image using &lt;strong&gt;media/upload&lt;/strong&gt; endpoint and the uploading subdomain. This means using &lt;em&gt;uploadClient&lt;/em&gt; here and returns an object with media_id attribute which we save for the next step.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Uploading an image
uploadClient.post('media/upload', { media_data: base64image })
    .then(media =&amp;gt; {

    console.log('You successfully uploaded media');

    var media_id = media.media_id_string;
}).catch(console.error);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You can see full details for this request &lt;a href="https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second request is the normal tweeting using &lt;strong&gt;statuses/update&lt;/strong&gt; endpoint to tweet with the image, which uses the &lt;em&gt;apiClient&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// tweeting with text and image
apiClient.post('statuses/update', { status: 'Hello world!', media_ids: media_id })
    .then(tweet =&amp;gt; {

    console.log('Your image tweet is posted successfully');
}).catch(console.error);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You can see full details for this request &lt;a href="https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-update" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;everything in place now and we can run the app in &lt;em&gt;Command Prompt&lt;/em&gt; using:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;That's it and your image is added to your tweet and takes its place in your friends timeline 😁.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's is the full code for index.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');
const path = require('path');
const config = require('./config');
const apiClient = config.newClient();
const uploadClient = config.newClient('upload');

const mediaFile = fs.readFileSync(path.join(__dirname, 'hello_world.png'));
const base64image = Buffer.from(mediaFile).toString('base64');

uploadClient.post('media/upload', { media_data: base64image })
    .then(media =&amp;gt; {

    console.log('You successfully uploaded media');

    var media_id = media.media_id_string;
    apiClient.post('statuses/update', { status: 'Hello world!', media_ids: media_id })
        .then(tweet =&amp;gt; {

        console.log('Your image tweet is posted successfully');
    }).catch(console.error);

}).catch(console.error);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the following tutorial, we are going to explore more about twitter API. I have several ideas to share with you, so stay tuned 😉&lt;/p&gt;

&lt;p&gt;For the full code, you can visit &lt;a href="https://github.com/amahallawy/MediaTweetBot" rel="noopener noreferrer"&gt;my github page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you like my tutorials, support me here &lt;a href="https://ko-fi.com/F2F41UH5T" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fko-fi.com%2Fimg%2Fgithubbutton_sm.svg" alt="ko-fi"&gt;&lt;/a&gt; and follow me on Twitter &lt;a href="https://twitter.com/ahmed_mahallawy" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Ftwitter%2Furl%2Fhttps%2Ftwitter.com%2Fahmed_mahallawy.svg%3Fstyle%3Dsocial%26label%3DFollow%2520%2540ahmed_mahallawy" alt="Twitter URL"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>twitter</category>
    </item>
    <item>
      <title>Building a Desktop PC for Coding</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Sat, 26 Dec 2020 22:09:58 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/building-a-desktop-pc-for-coding-4648</link>
      <guid>https://forem.com/ahmed_mahallawy/building-a-desktop-pc-for-coding-4648</guid>
      <description>&lt;p&gt;I just bought a new desktop PC, so I think this can be useful to other developers how I did that.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why I bought a PC not a laptop
&lt;/h1&gt;

&lt;p&gt;I had a power problem with my Asus TUF laptop and no one was able to solve it.&lt;br&gt;
If a similar problem happened in a desktop PC, it's easy to change the damaged part with less cost and less chance losing the whole machine.&lt;br&gt;
Also, desktop PCs are much powerful than laptops even with the same specifications.&lt;/p&gt;

&lt;h1&gt;
  
  
  My use
&lt;/h1&gt;

&lt;p&gt;When you buying a new PC (desktop or laptop), you must think carefully about how you going to use it. You don't want to buy the best computer that you'll use less than 10% of it's capabilities, or buy a cheap one that slows your work.&lt;br&gt;
My use is for programming, streaming, video editing, photoshop, and some gaming (only 2 games) &lt;br&gt;
This means that I need a powerful processor, good quality motherboard, fast reading and writing storage, an average graphics card, and good memory capacity.&lt;/p&gt;

&lt;h1&gt;
  
  
  My hardware choices
&lt;/h1&gt;

&lt;p&gt;I choose to go with AMD Ryzen 7 3700x processor, it has 8 cores and 16 threads with a very nice RGB cooler. Its benchmarks are very near to 10th gen i9 processors but with much less price. According to the CPU benchmark website, Ryzen 7 3700x (&lt;em&gt;$325&lt;/em&gt;) is better than Intel i9-10900x (&lt;em&gt;$560&lt;/em&gt;) &lt;a href="https://www.cpubenchmark.net/desktop.html" rel="noopener noreferrer"&gt;check the benchmark&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz7aa3tdlhh3fpihzn1me.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz7aa3tdlhh3fpihzn1me.png" alt="CPU benchmarks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiwj54xd5db650qjnf59r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiwj54xd5db650qjnf59r.jpg" alt="Processor"&gt;&lt;/a&gt;&lt;br&gt;
You can check it on Amazon from &lt;a href="https://amzn.to/3mS4HdN" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
For the motherboard, My first choice was Asus TUF gaming x570-plus with Wi-Fi (&lt;em&gt;$189&lt;/em&gt;) (see it on amazon from &lt;a href="https://amzn.to/38zuyC9" rel="noopener noreferrer"&gt;here&lt;/a&gt;) but It was out of stock. So, I chose Asus Rog Strix B550 gaming-f with Wi-fi (&lt;em&gt;$210&lt;/em&gt;). It's a very beautiful peace with support to PCIe gen 4, 2 M.2 SSD slots, can take up to 128Gb of RAM, has built-in Wi-fi, contains a USB type-c port, 2.5Gb LAN port, a USB 3.2 gen 2 port, and supports RGB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fimzz8q22n1wjsc4hnyf7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fimzz8q22n1wjsc4hnyf7.jpg" alt="Mother board"&gt;&lt;/a&gt;&lt;br&gt;
You can check it on amazon from &lt;a href="https://amzn.to/3ruqgo2" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
For the graphics card, I choose the Asus TUF GTX 1660 super (&lt;em&gt;$500&lt;/em&gt;) which has 6Gb of memory. It's a relatively new card with very good performance at a very affordable price.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fij2sddg0j4k0osv5bedh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fij2sddg0j4k0osv5bedh.jpg" alt="Graphics card"&gt;&lt;/a&gt;&lt;br&gt;
You can check it on amazon from &lt;a href="https://amzn.to/2WOOwmI" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
For the storage, I choose western digital black 500Gb SN750 NVMe Internal SSD (&lt;em&gt;$60&lt;/em&gt;) which has the highest quality of WD SSD drives.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjiw6tgiqtk1ow1rcgfha.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjiw6tgiqtk1ow1rcgfha.jpg" alt="SSD"&gt;&lt;/a&gt;&lt;br&gt;
You can check it on amazon from [here])&lt;a href="https://amzn.to/2KComRQ" rel="noopener noreferrer"&gt;https://amzn.to/2KComRQ&lt;/a&gt;)&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
For the memory, I choose the TEAMGROUP T-Force Vulcan Z 32Gb (16 x 2) DDR4 with 3600MHz (&lt;em&gt;$120&lt;/em&gt;) which is the best to be used with Ryzen processors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyuxv1tjawkb46af7h02z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyuxv1tjawkb46af7h02z.jpg" alt="RAM"&gt;&lt;/a&gt;&lt;br&gt;
You can check it on amazon from &lt;a href="https://amzn.to/37PRttG" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
Finally the computer case, I choose Corsair Carbide Series SPEC-DELTA RGB Mid-Tower ATX Case (&lt;em&gt;$50&lt;/em&gt;) which has a tempered glass side, 3 RGB fans in the front, 1 fan in the back, and with EVGA 600 W 80+ Certified ATX Power Supply (&lt;em&gt;$40&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhyz8hil67yr2lj9dpalw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhyz8hil67yr2lj9dpalw.jpg" alt="Corsair Case"&gt;&lt;/a&gt;&lt;br&gt;
You can check it on amazon from &lt;a href="https://amzn.to/3poqs6z" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
The total price was &lt;em&gt;$1305&lt;/em&gt;, prices are changing every day, so this may vary at your time of reading.&lt;/p&gt;

&lt;p&gt;If you like my tutorials, support me here &lt;a href="https://ko-fi.com/F2F41UH5T" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fko-fi.com%2Fimg%2Fgithubbutton_sm.svg" alt="ko-fi"&gt;&lt;/a&gt; and follow me on Twitter &lt;a href="https://twitter.com/ahmed_mahallawy" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Ftwitter%2Furl%2Fhttps%2Ftwitter.com%2Fahmed_mahallawy.svg%3Fstyle%3Dsocial%26label%3DFollow%2520%2540ahmed_mahallawy" alt="Twitter URL"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tech</category>
      <category>computer</category>
      <category>programming</category>
      <category>pcbuild</category>
    </item>
    <item>
      <title>Using Postman with Twitter API</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Sat, 26 Dec 2020 13:14:43 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/using-postman-with-twitter-api-1o46</link>
      <guid>https://forem.com/ahmed_mahallawy/using-postman-with-twitter-api-1o46</guid>
      <description>&lt;h1&gt;
  
  
  introduction
&lt;/h1&gt;

&lt;p&gt;This is my 3rd article on Twitter API series, so some information may need visiting my previous articles.&lt;/p&gt;

&lt;p&gt;Let's start...&lt;br&gt;
We don't need to write code to test a Twitter API endpoint. This can be done using Postman.&lt;br&gt;
According to their website: "Postman is used to Quickly and easily send REST, SOAP, and GraphQL requests".&lt;/p&gt;

&lt;h1&gt;
  
  
  Getting into Action
&lt;/h1&gt;

&lt;p&gt;You must have a Twitter developer account, to continue with this tutorial.&lt;br&gt;
Now, you'll download postman from &lt;a href="https://www.postman.com/downloads/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frwj9e1zb5wln01qbuuig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frwj9e1zb5wln01qbuuig.png" alt="Postman Download Page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may need to sign up to be able to use Postman. After that you can open it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjaa4ploet2i0mbh3jhdl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjaa4ploet2i0mbh3jhdl.png" alt="Postman"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There will be some configurations before dealing with Twitter API. First, you'll add an environment by clicking on the button in the following image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyuufm5smzppput8fbzez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyuufm5smzppput8fbzez.png" alt="Environment Button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A new window will appear as you can see in the following image, then click &lt;code&gt;Add&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnzj7wqtnkioj06qik2d3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnzj7wqtnkioj06qik2d3.png" alt="Manage Environments Window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can set your environment the same as the following image, you are free to choose the environment name. Use your Twitter account API key, API key secret, access token, and access token secret to filling the &lt;code&gt;Initial Value&lt;/code&gt; and &lt;code&gt;Current Value&lt;/code&gt; of the fields, then click &lt;code&gt;Add&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fky2rs3atihj40xyk8ky7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fky2rs3atihj40xyk8ky7.png" alt="Environment Configurations"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have an environment that you can use by selecting it from the environment's dropdown list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft5lp3svttkljii98fint.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft5lp3svttkljii98fint.png" alt="Environment's Dropdown List"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, you need to open a new request by clicking the &lt;code&gt;+&lt;/code&gt; button or by clicking &lt;code&gt;Create a request&lt;/code&gt; from the Launchpad of Postman.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frk1lpzhjc2uru9mqzrjn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frk1lpzhjc2uru9mqzrjn.png" alt="Create a Request"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use the following endpoint to get tweets of a specific account, see the documentation &lt;a href="https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
&lt;code&gt;&lt;br&gt;
https://api.twitter.com/1.1/search/tweets.json&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add this endpoint to the textbox after the word GET as you can see in the following image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhuby3q50sk3s2yg7nlgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhuby3q50sk3s2yg7nlgi.png" alt="Request Endpoint"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, click on the &lt;code&gt;Authorization&lt;/code&gt; button. In the Type dropdown, select &lt;code&gt;OAuth 1.0&lt;/code&gt;. The OAuth parameters will appear on the right and will be filled with the environment variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjacm3lmfw586t7xajwsf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjacm3lmfw586t7xajwsf.png" alt="Authorization Types"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One last step, according to Twitter documentation, this endpoint requires a &lt;code&gt;q&lt;/code&gt; parameter which is a query text used to search tweets. To add this parameter, click on the &lt;code&gt;Params&lt;/code&gt; button and add the parameter key and value as in the following image and make sure the checkbox beside the parameter key is checked ☑.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjsm3hoe4zfp8na6v77zn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjsm3hoe4zfp8na6v77zn.png" alt="Request Params"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will change the endpoint to look like that&lt;br&gt;
&lt;code&gt;&lt;br&gt;
https://api.twitter.com/1.1/search/tweets.json?q=ahmed_mahallawy&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Finally, You can click the blue &lt;code&gt;Send&lt;/code&gt; button, and see the results. If you get a 200 OK status as the following image, this means you did it successfully 🎉&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feyec10nnuz47lreth3na.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feyec10nnuz47lreth3na.png" alt="Successfull Request"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all. 💪&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Using Postman can be very useful to test Twitter API for your use cases before building your applications. That's why it's very important to understand how to use it.&lt;/p&gt;

&lt;p&gt;If you like my tutorials, support me here &lt;a href="https://ko-fi.com/F2F41UH5T" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fko-fi.com%2Fimg%2Fgithubbutton_sm.svg" alt="ko-fi"&gt;&lt;/a&gt; and follow me on Twitter &lt;a href="https://twitter.com/ahmed_mahallawy" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Ftwitter%2Furl%2Fhttps%2Ftwitter.com%2Fahmed_mahallawy.svg%3Fstyle%3Dsocial%26label%3DFollow%2520%2540ahmed_mahallawy" alt="Twitter URL"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>twitter</category>
      <category>postman</category>
      <category>api</category>
    </item>
    <item>
      <title>A 14 years journey of programming</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Wed, 02 Dec 2020 19:32:53 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/a-14-years-journey-of-programming-5fk</link>
      <guid>https://forem.com/ahmed_mahallawy/a-14-years-journey-of-programming-5fk</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I grow up in &lt;a href="https://en.wikipedia.org/wiki/Tanta"&gt;Tanta, Egypt&lt;/a&gt;, and I'm an Electric Communications and Electronics Engineer. Didn't I tell you my name yet? Oh, silly me. It's Ahmed El-Mahallawy.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The Very Beginning
&lt;/h2&gt;

&lt;p&gt;Studying for an engineering degree was really boring for me. I didn't care much for studying Fortran and C in college. So, when asked "when did I start programming?", I never say in college.&lt;/p&gt;

&lt;h2&gt;
  
  
  First Step
&lt;/h2&gt;

&lt;p&gt;I graduated in 2004 and worked in some engineering jobs that I didn't enjoy. In 2006, I was lucky 🤞 to be selected to work in a governmental &lt;a href="https://en.wikipedia.org/wiki/Cairo"&gt;Cairo, Egypt&lt;/a&gt; based company in the IT department. I did very well in the interview and exam, which led me to work in the &lt;a href="https://en.wikipedia.org/wiki/Geographic_information_system"&gt;GIS (Geographic Information System)&lt;/a&gt; section.&lt;br&gt;
I was told you need to learn programming, I was thrilled and answered "Yes, I love programming".&lt;br&gt;
Then, I started learning VB6 (Visual Basic 6) from a book. Then, it was time to write my own code without following book instructions. I was thinking I'm totally ready 😏 but found that coding is much harder than I thought, and googling information back then was so limited. I had to read a lot of documentation and practice by try and error. As a result, I learned VB6, ArcObjects SDK for VBA, Microsoft Access databases. &lt;/p&gt;

&lt;h2&gt;
  
  
  Second Step
&lt;/h2&gt;

&lt;p&gt;After a while, I started gaining more confidence and exploring C#, WPF, PHP, MySql.&lt;br&gt;
Learning more technologies helped me landing my second job in 2013 with the title Senior GIS Developer. It was in &lt;a href="https://en.wikipedia.org/wiki/Jeddah"&gt;Jeddah, Saudi Arabia&lt;/a&gt;, so I had to relocate with my family.&lt;br&gt;
It was challenging, as I had to work with technologies I don't know such as Oracle database, ArcGIS Server, Silverlight, ArcGIS API for Silverlight, and I was up to the challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  My First Web Programming Job
&lt;/h2&gt;

&lt;p&gt;In 2015, I got my third job and it was in &lt;a href="https://en.wikipedia.org/wiki/Ta%27if"&gt;Taif, Saudi Arabia&lt;/a&gt; with the title Expert GIS Developer. The job was all about web programming that wasn't my expertise. So, I had to learn more about HTML and CSS and take JavaScript more seriously. I also learned ArcGIS API for JavaScript, jQuery, Dojo Toolkit, Bootstrap, Node JS, Angular 2+, MongoDB, and Firebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;In 2018, I decided not to work exclusively in GIS, because of the lack of good working opportunities. I moved to a new company to lead a team to build some amazing web apps, but the company failed us 😰.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nowadays
&lt;/h2&gt;

&lt;p&gt;Now, I got back to Egypt and I have a stable job now as an Expert Web Developer. After the Covid-19 lockdown, I discovered a great community on Twitter for developers. This community showed support to me 🥰 and made me believe that I can contribute more to other developers in the world.&lt;br&gt;
I started blogging here in Dev.to, shared some of my ideas in Codepen.io, taught JavaScript to some code newbies, and lately gave a talk about Node JS, and soon starting a coding channel on Youtube.&lt;/p&gt;

&lt;p&gt;Check my Articles here in Dev.to 📝&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/ahmed_mahallawy/tweeting-using-node-js-5986"&gt;Tweeting using Node JS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/ahmed_mahallawy/like-retweet-and-follow-in-twitter-using-node-js-5gbc"&gt;Like, Retweet, and Follow in Twitter using Node JS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you like my tutorials, support me here &lt;a href="https://ko-fi.com/F2F41UH5T"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FKanlt08--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ko-fi.com/img/githubbutton_sm.svg" alt="ko-fi"&gt;&lt;/a&gt; and follow me on Twitter &lt;a href="https://twitter.com/ahmed_mahallawy"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sBVgvPos--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/twitter/url/https/twitter.com/ahmed_mahallawy.svg%3Fstyle%3Dsocial%26label%3DFollow%2520%2540ahmed_mahallawy" alt="Twitter URL"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>biography</category>
      <category>work</category>
      <category>life</category>
      <category>learn</category>
    </item>
    <item>
      <title>سؤال للمبرمجين العرب</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Mon, 03 Aug 2020 01:21:15 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/-353m</link>
      <guid>https://forem.com/ahmed_mahallawy/-353m</guid>
      <description>&lt;p&gt;ايه رأيكم نكتب مقالات تقنية باللغة العربية هنا؟&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Like, Retweet, and Follow in Twitter using Node JS</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Sun, 02 Aug 2020 13:08:25 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/like-retweet-and-follow-in-twitter-using-node-js-5gbc</link>
      <guid>https://forem.com/ahmed_mahallawy/like-retweet-and-follow-in-twitter-using-node-js-5gbc</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;In the previous tutorial, I built a node js application with the help of &lt;a href="https://github.com/draftbit/twitter-lite"&gt;twitter lite&lt;/a&gt; to add a new tweet to Twitter. You can see the tutorial &lt;a href="https://dev.to/ahmed_mahallawy/tweeting-using-node-js-5986"&gt;here&lt;/a&gt;.  &lt;/p&gt;

&lt;p&gt;In this new tutorial, we'll make a similar application to like a tweet, retweet, and follow a twitter user. The new application follows the same structure used in the previous one. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Application
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;As we did in the previous tutorial, We should have 2 files, the first one is config.js that contains twitter lite configurations, and the second file is index.js which contains the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const config = require('./config');
const twitter = require('twitter-lite');
const client = new twitter(config);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We'll use my twitter account to explain how to like, retweet, and follow. So first, we'll search for my account using twitter API:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Get twitter user
client.get('users/show', { screen_name: 'ahmed_mahallawy' })
    .then(result =&amp;gt; {

    var user = result;
    var latestTweet = result.status;
}).catch(console.error);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This code makes a get request to 'users/show' endpoint that retrieves user data using my screen name (screen name in twitter is the one preceded by @). You can see full details for this request &lt;a href="https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-show"&gt;here&lt;/a&gt;.
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We'll save the result in &lt;strong&gt;&lt;code&gt;user&lt;/code&gt;&lt;/strong&gt; variable and the user’s latest tweet in &lt;strong&gt;&lt;code&gt;latestTweet&lt;/code&gt;&lt;/strong&gt; variable using &lt;strong&gt;&lt;code&gt;result.status&lt;/code&gt;&lt;/strong&gt;, so we can use both of them later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To like the selected tweet, we'll use a post request to 'favorites/create' endpoint that will add a like to tweet using the tweet id_str attribute:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Like a tweet using its id_str attribute
client.post('favorites/create', { id: latestTweet.id_str })
    .then(result =&amp;gt; {

    console.log('Liked tweet successfully!');
}).catch(console.error);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can see full details for this request &lt;a href="https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-create"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Now, we make a retweet in a very similar way of liking. We'll make a post request to 'statuses/retweet' endpoint that will make retweet using the tweet id_str attribute:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Retweet a tweet using its id_str attribute
client.post('statuses/retweet', { id: latestTweet.id_str })
    .then(result =&amp;gt; {

    console.log('Retweeted successfully!');
}).catch(console.error);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can see full details for this request &lt;a href="https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-retweet-id"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Finally, we follow the user by making a post request to 'friendships/create' endpoint using the user screen name:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Follow a user using his/her screen_name attribute
client.post('friendships/create', { screen_name: user.screen_name })
    .then(result =&amp;gt; {

    console.log('Followed ' + user.screen_name + ' successfully!');
}).catch(console.error);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can see full details for this request &lt;a href="https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create"&gt;here&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;We wrote all the required code, and now we can run it from cmd using the command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations! &lt;br&gt;
You did it!!!!!!!!!! 💪  &lt;/p&gt;

&lt;p&gt;Here's is the full code for index.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const config = require('./config');
const twitter = require('twitter-lite');
const client = new twitter(config);

// Get twitter user
client.get('users/show', { screen_name: 'ahmed_mahallawy' })
    .then(result =&amp;gt; {

    var user = result;
    var latestTweet = result.status;

    // Like a tweet using its id_str attribute
    client.post('favorites/create', { id: latestTweet.id_str })
        .then(result =&amp;gt; {

        console.log('Liked tweet successfully!');
    }).catch(console.error);

    // Retweet a tweet using its id_str attribute
    client.post('statuses/retweet', { id: latestTweet.id_str })
        .then(result =&amp;gt; {

        console.log('Retweeted successfully!');
    }).catch(console.error);

    // Follow a user using his/her screen_name attribute
    client.post('friendships/create', { screen_name: user.screen_name })
        .then(result =&amp;gt; {

        console.log('Followed ' + user.screen_name + ' successfully!');
    }).catch(console.error);
}).catch(console.error);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the following tutorial, we are going to explore more about twitter API. I have several ideas to share with you, so stay tuned 😉&lt;/p&gt;

&lt;p&gt;For the full code, you can visit &lt;a href="https://github.com/amahallawy/LikeRetweetFollowBot"&gt;my github page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you like my tutorials, support me here &lt;a href="https://ko-fi.com/F2F41UH5T"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FKanlt08--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ko-fi.com/img/githubbutton_sm.svg" alt="ko-fi"&gt;&lt;/a&gt; and follow me on Twitter &lt;a href="https://twitter.com/ahmed_mahallawy"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sBVgvPos--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/twitter/url/https/twitter.com/ahmed_mahallawy.svg%3Fstyle%3Dsocial%26label%3DFollow%2520%2540ahmed_mahallawy" alt="Twitter URL"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>twitter</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Tweeting using Node js</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Sat, 25 Jul 2020 14:24:35 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/tweeting-using-node-js-5986</link>
      <guid>https://forem.com/ahmed_mahallawy/tweeting-using-node-js-5986</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Twitter is a great social media platform where you can interact with a lot of people all over the world. But you can use twitter in a different way, &lt;strong&gt;the Developers Way&lt;/strong&gt;. You can do that by consuming the Twitter API.&lt;/p&gt;

&lt;p&gt;Twitter API gives you the capability to do what you do on twitter but from outside of it. You can build applications that can tweet, message, like, and retweet. There are many ways to do that, but here you’ll build an application using Node js.&lt;/p&gt;

&lt;p&gt;Here you’ll use only Node Js and twitter lite to post tweets to your account.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a twitter developer account
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;First, you’ll need to have a developer account on Twitter, you can apply for it at &lt;a href="https://developer.twitter.com/en" rel="noopener noreferrer"&gt;Twitter Developer Website&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;After you created the developer account, log in to it
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx7wslh3jli6iqrjj1h3c.png" alt="Twitter developer website"&gt;
&lt;/li&gt;
&lt;li&gt;Create an App by clicking on &lt;strong&gt;Dashboard&lt;/strong&gt; in the top right of the page, then under &lt;em&gt;Standalone Apps&lt;/em&gt; click on &lt;strong&gt;+ Create App&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Then you’ll only choose a unique name for your App&lt;/li&gt;
&lt;li&gt;That’s great. Now you have an App on twitter. We’ll get back to it in a few minutes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using Node JS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you don’t have Node js yet, you have to install it from &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node JS website&lt;/a&gt; and choose the LTS version.&lt;/li&gt;
&lt;li&gt;If you have it installed check its version in cmd using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now start building the application by creating a folder and name it TweetBot (you can change the name).&lt;/li&gt;
&lt;li&gt;Open cmd and type the following command to create package.json file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then add the twitter lite using npm with the command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install –save twitter-lite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Open VSCode or any code editor and create a file and name it config.js and add the twitter-lite configurations as follows:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {  
  consumer_key: ' ' ,  
  consumer_secret: ' ',  
  access_token_key: ' ',  
  access_token_secret: ' '  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The configuration values can be found in the app you created in the twitter developer website under &lt;em&gt;Keys and Tokens&lt;/em&gt; link.
&amp;gt;The latest twitter changes included changing the consumer key name to be API key, and consumer secret name to be API key secret.&lt;/li&gt;
&lt;li&gt;You may need to generate access token and secret.&lt;/li&gt;
&lt;li&gt;Now create an index.js file and start it by adding the configuration file and twitter-lite to the app as follows:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const config = require('./config');
const twitter = require('twitter-lite');
const client = new twitter(config);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then, you create a request for the Twitter API.&lt;/li&gt;
&lt;li&gt;For tweeting, we can use the post request 'statuses/update'. You can see full details for this request &lt;a href="https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You'll use twitter lite to handle the request (for more information about twitter lite visit &lt;a href="https://github.com/draftbit/twitter-lite" rel="noopener noreferrer"&gt;their Github page&lt;/a&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.post('statuses/update', { status: 'Hello world!' }).then(result =&amp;gt; {
  console.log('You successfully tweeted this : "' + result.text + '"');
}).catch(console.error);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This post method consists of 2 parts: the first is the endpoint text (which is 'statuses/update'), the second is a parameter object that requires a status attribute that contains the text to be tweeted.&lt;/li&gt;
&lt;li&gt;If the request is successful, the result object will contain all tweet information. If an error happens, the catch method will log it to the console.&lt;/li&gt;
&lt;li&gt;Now go to cmd and type:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;And voila!!! You tweeted from your application 💪&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the following tutorial, we will make like, retweet and follow bot, so stay tuned 😉&lt;/p&gt;

&lt;p&gt;For the full code, you can visit &lt;a href="https://github.com/amahallawy/TweetBot" rel="noopener noreferrer"&gt;my github page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you like my tutorials, support me here &lt;a href="https://ko-fi.com/F2F41UH5T" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fko-fi.com%2Fimg%2Fgithubbutton_sm.svg" alt="ko-fi"&gt;&lt;/a&gt; and follow me on Twitter &lt;a href="https://twitter.com/ahmed_mahallawy" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Ftwitter%2Furl%2Fhttps%2Ftwitter.com%2Fahmed_mahallawy.svg%3Fstyle%3Dsocial%26label%3DFollow%2520%2540ahmed_mahallawy" alt="Twitter URL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pictures used in cover are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.freepik.com/free-photos-vectors/computer" rel="noopener noreferrer"&gt;Computer photo created by pressfoto&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freepik.com/free-photos-vectors/social-media" rel="noopener noreferrer"&gt;Social media vector created by stories&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>twitter</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>SVG Text Editor</title>
      <dc:creator>Mahallawy </dc:creator>
      <pubDate>Tue, 07 Jul 2020 13:27:46 +0000</pubDate>
      <link>https://forem.com/ahmed_mahallawy/svg-text-editor-3jl2</link>
      <guid>https://forem.com/ahmed_mahallawy/svg-text-editor-3jl2</guid>
      <description>&lt;p&gt;This is a small project I'm working on &lt;iframe height="600" src="https://codepen.io/amahallawy/embed/qBbpbgj?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This pen has been featured in &lt;a href="https://codepen.io"&gt;codepen&lt;/a&gt; yesterday and I thought of sharing it with Dev Community here too.&lt;/p&gt;

&lt;p&gt;For cover image I used resources from &lt;a href="https://www.freepik.com"&gt;freepik&lt;/a&gt;: &lt;br&gt;
&lt;a href="https://www.freepik.com/free-photos-vectors/business"&gt;Business vector created by studiogstock&lt;/a&gt; &lt;br&gt;
&lt;a href="https://www.freepik.com/free-photos-vectors/background"&gt;Background vector created by starline&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
  </channel>
</rss>
