Laravel Passport: API implementation using Laravel Passport

In this tutorial we will see about API implementation using Laravel Passport.

First of all we need to install passport. Install Passport via the Composer package manager.Please find below the command.

$ composer require laravel/passport

The Passport service provider registers its own database migration directory with the framework, so you should migrate your database after installing the package. The Passport migrations will create the tables your application needs to store clients and access tokens.Below command is for migrate.

$ php artisan migrate

Below command will create the encryption keys needed to generate secure access tokens.

$ php artisan passport:install

After running the passport:install command, add the Laravel\Passport\HasApiTokens trait to your App\User model.

<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable{
    use HasApiTokens, Notifiable;
}

Now we will call the Passport::routes method within the boot method of AuthServiceProvider. This method will register the routes necessary to issue access tokens and revoke access tokens, clients, and individual access tokens:

class AuthServiceProvider extends ServiceProvider{
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];
    public function boot(){
        $this->registerPolicies();
        Passport::routes();
    }
}

Next, we will update config/auth.php configuration file, you should set the driver option of the api authentication guard to passport.

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],

Now will create controller.Please find below the command to create a controller.

$ php artisan make:controller API/LoginController

Next, we will configure routes.

Route::post('/register','API\LoginController@register');
Route::post('/login','API\LoginController@login');

Register function is to registre new users.Below code is for register.

 public function register(Request $request){
        $validateData = $request->validate([
            'email' => 'required|email',
            'password' => 'required|min:5|max:20',
        ]);
 
        $validateData['password'] = bcrypt($request->password);
        $user = User::create($validateData);
        $accessToken = $user->createToken('authToken')->accessToken;
        return response()->json(['user'=> $user,'access_token'=>$accessToken]);
    }

Now we will test API through postman.If you want to know more about API testing through postman you can visit this link Test API through postman

Now will test our login process through postman. Below image for your reference.

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help! Stay tuned!

Integrate ICICI EazyPay payment gateway to your website

In this tutorial I would like to explain how to integrate Eazypay into your website.I am using Codeigniter to integrate eazypay.

Register and get you Merchant details through registration in ICICI Eazypay

To encrypt all parameter you can use eazypay inbuilt function of encryption.Please find below the code

function eazypayu_aes128Encrypt($plaintext,$key){
      $cipher = "AES-128-ECB";   
      if (in_array($cipher, openssl_get_cipher_methods())){
       $ivlen = openssl_cipher_iv_length($cipher);
       $iv = openssl_random_pseudo_bytes($ivlen);
       $ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv);
       return $ciphertext;
      }
}

To process your payment you have to take input from user and after thet serialize all data and set as parameter value.Below code is for reference.

public function make_payment() {
	$amount = $this->input->post('amount');
	$merchant_id = "YOUR MERCHANT ID";
	$key = "YOUR MERCHANT KEY";
	$reference_no = 2; 
	$sub_merchant_id = "YOUR SUBMERCHANT ID";
	$return_url = "YOUR REGISTERED RETURN URL";
	$paymode = "9";
	$mandatory_fields = $reference_no ."|".$sub_merchant_id ."|".$amount;
	$opt_fields = "";
	$e_sub_merchant_id = $this->eazypayu_aes128Encrypt($sub_merchant_id, $key);
	$e_reference_no = $this->eazypayu_aes128Encrypt($reference_no, $key);
	$e_amount = $this->eazypayu_aes128Encrypt($amount, $key);
	$e_return_url = $this->eazypayu_aes128Encrypt($return_url, $key);
	$e_paymode = $this->eazypayu_aes128Encrypt($paymode, $key);
	$e_mandatory_fields = $this->eazypayu_aes128Encrypt($mandatory_fields, $key);
	
	$redirect_url = 'https://eazypay.icicibank.com/EazyPG?merchantid='.$merchant_id.'&mandatory fields='.$e_mandatory_fields.'&optional fields='.$opt_fields.'&returnurl='.$e_return_url.'&Reference No='.$e_reference_no.'&submerchantid='.$e_sub_merchant_id.'&transaction amount='.$e_amt.'&paymode='.$e_paymode.'"';		

	redirect($redirect_url );
    		
}

After payment done you have to capture response getting from return URL. Here is the sample code to capture the response.

 public function success(){
        $res = $_REQUEST;
        $data_transaction = array(
        'Response_Code'=> $res['Response_Code'],
        'Unique_Ref_Number'=> $res['Unique_Ref_Number'],
        'Service_Tax_Amount'=> $res['Service_Tax_Amount'],
        'Processing_Fee_Amount'=> $res['Processing_Fee_Amount'],
        'Total_Amount'=> $res['Total_Amount'],
        'Transaction_Amount'=> $res['Transaction_Amount'],
        'Transaction_Date'=> date('Y-m-d',strtotime($res['Transaction_Date'])),
        'Interchange_Value'=> $res['Interchange_Value'],
        'TDR'=> $res['TDR'],
        'Payment_Mode'=> $res['Payment_Mode'],
        'SubMerchantId'=> $res['SubMerchantId'],
        'ReferenceNo'=> $res['ReferenceNo'],
        'ID'=> $res['ID'],
        'RS'=> $res['RS'],
        'TPS'=> $res['TPS'],
        'mandatory_fields'=> $res['mandatory_fields'],
        'optional_fields'=> $res['optional_fields'],
        'RSV'=> $res['Response_Code'],
        '_policy'=> $res['_policy'],
        'visitor'=> $res['visitor']
        );
        
        $this->db->insert('tbl_all_payments', $data_transaction);
        
        $this->load->view('success_page');
        
    }

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help! Stay tuned!

Create Your Facebook Business Page Step By Step

A business page on Facebook gives you an approach to discuss straightforwardly with your intended interest group. How to Create a business page on Facebbok ? I will explain with simple steps.Just follow me.

First of all, you must have a Facebook account. If you are not already, first create a Facebook account.

  1. Sign Up

Go to facebook.com/pages/create.Choose the type of page you want to create: business / brand or community / public figure. In this post you are creating a page for the business or brand, so click on the Get Started button for that option.

In the next step, enter your business information. For the name of your page, use the name of your business or the name that people are likely to find when trying to find your business.

For the category, write a word or two that describes your business and Facebook will suggest some options. If your business falls into more than one category of options, then choose your customers to think about your business.

Once you select your category, the box will expand to ask for some more details such as your address and phone number. You can choose whether this information is made public or only shown to your city and state.

When you are ready, click Continue. Note that doing so reflects your acceptance of Facebook’s page, group and event policies, so you can check this before proceeding.

2.Profile and a Cover Photo

Next, you will upload a profile for your Facebook page and cover the images. It is important to make a good visual first impression, Make sure that the pictures you choose align with your brand and are easily identifiable with your business.

You will upload your profile image first. This image along with your business name in search results and when you interact with users. It also appears on the top left of your Facebook business page.

Once you have selected a great photo, click Upload Profile Picture.

Now it’s time to choose your cover image, which is the most prominent image on your Facebook business page.

Once you have selected a suitable image, click Upload a cover photo.

3. Change your Facebook page URL

After uploading (or skipping) your pictures, your page will be generated. The first thing you want to do is change the URL of your page.

By changing the URL, you make it easy for users to remember it. To do this, you have to click on the “View More” tab on the left panel and click on “About”. The following page will appear.

Then you click on the “Create Page @username” option and another box will appear in which you can type your username.

If it is available then you can create a username and the URL of your page will also change according to the user.

4.Fill in the information under the “About” tab

With the details filled in, you want to go back to the “About” tab and fill in all your information. It is as important as possible that when visitors come to the page, they can get all the necessary information.

Now, you will not want to share your number or some other information. This is completely fine, you can fill it as much as you want but make sure to be full of basics such as website, company overview, installation date and e-mail.

5.Add your business details

From the beginning it is necessary to fill all fields in the “About” section of your Facebook page.

To start filling in your business details, click “Edit Page” Information in the top menu. From this screen you can share all important information about your business.

Description

This is a brief description that appears in the search results. It should be only a few sentences, so there is no need to be too elaborate here.

Categories

Here you will see the category entered in step 1. If you wish, you can add additional categories here to ensure that Facebook shows your page to all the right people.

Contact

Want to make all contact details public including your phone number, website and email.

6.Promote your page

One reason for setting up a page for your page is that you can reach a wider audience. Facebook lets you do this with the option to promote your page.

You can do this by clicking on the “Promot” option in the sidebar. It is important that you have all your information and posts are already posted on the page so that once Facebook promotes your page, your visitors actually have something to interact with. The following page will then appear to select your promotional goal:

Review your settings

To access your settings, simply click Settings at the top right of your Facebook page.

Check your settings regularly, as your preferences and requirements may change as your business – and social following grows

For even more control over who can control your page, consider setting up Facebook Business Manager to control the roles filled by team members, contractors and agencies.

Conclusion

With this, your page gets setup on Facebook and in no time, you will experience more traffic to your page. The page setup process is quite easy, what can be difficult is how you promote the page. As long as you monitor your promotional efforts, you should make a strategy in no time. All of which will help you gain more fans and readers for your page.

React Native Vs. Flutter: A better choice for 2020

Are you looking for developing mobile apps more quickly at a reduced cost? And choosing the best technology for your app is giving you a  pain in the neck? Well, today in this article we’ll discuss the prime market leaders, flutter by google, and react native by Facebook. Because Flutter and react-native always make up to the developer’s final lists. Every growing industry is inclined towards mobile applications to stay relevant in the business world. Consequently, it becomes a need to choose the best platform with high speed and fewer resources that can build native apps without using Swift for iOS or Java for android. So in this post, we will compare both of these platforms from a developer’s vision. So that you can make the best choice according to your business needs.

What is flutter?

Flutter was introduced by Google in 2017. It is a UI toolkit used for developing an application for ios, windows, mac, android, and Linux. It. It is a cross-platform mobile development framework that uses the Dart language (a fast object-oriented language). It’s a free and open-source project, however, both Google and the flutter community participate in the growth and improvement of the platform. Top apps like google ads, Hamilton app, Xianyu app by Alibaba, the app for JD finance are created by flutter.

What is react native?

 On the other hand, native react is an open-source mobile application framework unveiled by Facebook in the year 2015. It is used for developing applications for both Android and iOS using a single codebase. It uses javascript as its language. Popular applications like Facebook, Instagram, Pinterest, Wix, skype, and Facebook ads manager are created using react native platform.

In recent years cross-platform mobile development has gained much popularity because it enables you to develop a mobile application that runs on more than one platform. And  If you are confused between which one should I go for? flutter or react native, then there is no exact answer to that. The right answer depends on your use cases and your business needs. Perhaps, you can consider some points that can push you to the crux of the matter. So let’s get started with the comparison. Here are some points that we will consider for comparison:-

  1. Hot reload support:- For hot reloading, both flutter and react-native got equal points. Because both include hot reloading. Hot reloading means, you inject code, save that code, and reload it on the mobile app at runtime. This is such an amazing feature that every single developer, who is working on native code, really misses out a lot.
  2. Unveiling date:- Now you might be wondering, how unveiling date can be a criterion. But the release date holds high potential. Because the member who is getting first into the market, always gets the upper hand in the competition. And here react-native was the first to land in the market. Although there are only two years of difference, flutter is giving tough competition and its community support is growing rapidly.
  1. Components:- We can design any component in both of them. But here is the twist. In react native, you get dearth of groundbreaking options to experiment with. You get a handful of things, which can be an advantage because you have to learn very fewer things but you can create any component using a third-party library. On the contrary, flutter is rich in UI components. If you don’t like to work with third-party components, you can go with flutter. 
  2. Programming language:-Flutter uses dart as a programming language and react native uses javascript as its programming language. Here, react-native can have the upper hand. Because there is a huge community in the programming world that is working in javascript and dart can seem tougher to them in that context. So migrating into the mobile apps with react native can be a piece of cake, rather than learning a whole new language. Dart has also great features but it is less known in the programming community.
  3. Documentation:- On this point, my stars are clearly with flutter. The reason behind it that google provides well-written documentation of its products. And Flutter is no exception. For react native, we have to look at third-party documentation which is not much fun.
  4. Industry’ adaptation:– This is still a contentious question to put on. Because different people see this from different perspectives. There is no doubt people are adopting for flutter but a lot of companies are already working on react native.
  5. Community support:– There is no point of debate that the ball is in the react native’s court. As react native was released earlier than the flutter, it has grown its popularity. However, flutter is new, but it is fairly growing its community faster.
  6. Performance:– React native has a JavaScript bridge to interact with the native component, which restricts the performance to a small extent. But unlike react native, flutter doesn’t need any javascript bridge to interact with native components. Dart code is combined with the native machine code which eradicates the need for javascript bridge. This improves flutter’s performance.

The bottom line

It is a very fascinating time for mobile application development. The developer community is slightly moving away from old technologies and taking it to the next level. However, both the platforms reduce time and cost, and in addition to that, their third party libraries and ready to use components make it more effective to use them or build an app. And these are the key reasons based on which you can choose a framework for your app development. If you know dart, then choosing Flutter for you will be a no brainier, and If you operate with javascript, go with react native. If you want to build your app’s GUI using native components, you can pick react native. And if the brand first design is your priority, then flutter can be the better choice for you. Although flutter and react-native have their pros and cons. But in the above comparison, flutter seems to wins the race of choosing platforms. But let’s not predict the future of these platforms and see what time has contained for us.

ASP.NET VS PHP: Side-by-Side Comparison

ASP.NET and PHP are popular languages in the programming world that are used by a large number of developers and make it difficult for new developers to choose one of them. Both of these languages are used in large web-based applications. Some successful companies like Google, Facebook and Twitter etc. also use these languages.

PHP

PHP stands for Hypertext Preprocessor. It is an open source programming language used for web development and can be embedded into HTML. The best part of PMP is that it is free and has a ton of frameworks, which simplifies web development and is simple even for beginners as it is simple and easy coding technique. PHP is great for professionals due to its advanced features.

Why use a PHP framework?

A PHP framework provides a basic structure to streamline the development of web apps. Applications and websites built using the PHP framework will help businesses improve their performance requirements.

The best PHP frameworks available:

  • Laravel
  • CodeIgniter
  • Symfony
  • Zend
  • Phalcon
  • CakePHP
  • Yii
  • FuelPHP

Demand for PHP Developer:

In Today’s web development market, most websites are developed using PHP development tools which indicates a huge demand for PHP developers. If you want to enter the IT world as a developer, PHP programming will be an easy entry point.

Getting PHP training from an authentic and reliable training provider will be a great platform to improve your skills.

ASP.NET

ASP.NET is an open-source server-side web development tool developed by Microsoft for easy creation of web applications and web pages. It can be written using any .Net supported language which makes it more popular among .NET developers. High speed and low cost are the main reasons for using it. A website built by ASP.NET is faster and more efficient than a website built with PHP.

Demand for ASP.NET Developer:

If you are a .NET developer, you will find yourself sought after by many asp.net development companies because your programming skills are extremely valuable in today’s market. There are many companies hunting for developers who can do programming with .NET. Therefore, it is advised that you brighten up your skills with ASP.NET certification training, which will increase your value manifold and have an edge over others. The ASP.NET certification training program will definitely make your future brighter and increase your career opportunities.

Comparison Between ASP.NET and PHP

Both the ASP.NET and PHP frameworks are effective frameworks to work with, however, there may be some advantages over the other. Let’s take a deeper look and compare these frameworks to understand which one is better than the other.

2. Market Share

According to the report, the underlying data source PHP is the most commonly used programming language with a 73% market share, with ASP.NET having a 23% market share. PHP has a 58% market share among the top 100K websites and PHP has a 52% market share among the 10K websites.

2. Websites

Here are two lists for comparing ASP.NET vs. PHP websites:

Websites built using PHPWebsites built using ASP.NET
Wikipedia
Facebook
Yahoo
WordPress.com
iStockPhoto
Microsoft
Dell
GoDaddy

3. Inbuilt features

PHP has many unique built in features that can help web developers. On the other side, ASP.NET has no such feature.

4. Speed and Performance

When you compare PHP vs. ASP.NET for speed, PHP will be the winner. ASP.NET is slightly slower than PHP because it is built on COM based systems whereas, the PHP program runs on its own memory space.

5. Community Support

Compared to ASP.NET, learning support is great in the PHP framework and has a large support community. It will be difficult for you to get hold of the #C language of ASP.NET as it is difficult to understand.

Key differences between ASP.NET vs PHP

PHPASP.NET
PHP was launched in 1995 by Rasmus Lerdorf.ASP.NET was launched by Microsoft in the year 2002.
PHP is Scripting languageASP.NET is a paid Microsoft provided web application framework.
PHP Suite for Small Size OrganizationsASP.NET is suitable for a large and medium sized organization.
PHP has a good market share in the marketASP.NET has more market share
PHP works slow for desktop applicationsASP.NET is well equipped to support and create desktop applications.
PHP is best suited for applications that have a core focus on the UIASP.NET is better for applications where the main concern is security.
easy to learnQuite challenging to learn.
PHP is easier to use than all other languagesCoding with ASP.NET is complicated
Since it uses built in memory space, PHP execution is fasterCoding with ASP.NET is complex
PHP can run on Linux operating system which is available for freeASP.NET requires a Windows platform that is not free

Conclusion

Both PHP and ASP.NET come with their pros and cons. PHP is safe, fast, reliable and inexpensive and ASP.NET is easy to use and maintain due to its class library system. Since both programming languages are similar and provide similar results, the company can make a choice based on the needs and requirements of the app they are about to develop.

Generate and Setup SSH Key to Your GitLab Account

SSH stands for Secure Shell or Secure Socket Shell used for managing the networks and also authenticates to the GitLab server without using username and password each time. You can set the SSH keys to make a secure connection between the computer and GitLab.

Download GitBash

Git Bash is an application for Microsoft Windows environments which provides all git features in command line plus most of standard Unix commands.To download Git BAsh click here.After downloading the Git Bash open and run this below command

ssh-keygen

After running above command it will prompt for
“Enter file in which to save the key (//.ssh/id_rsa):”, just type file name and press enter. Next a prompt to enter password shows
“Enter passphrase (empty for no passphrase):”.
Then again you will be asked for
“Enter same passphrase again:”.
Just hit enter.You will see the generated SSH key as shown in the below image.

Set SSH Key to your GitLab Account

To set SSH key login to your GitLab account and click on the Settings option.

And in the left side menu click on SSH keys.See below image for your reference.

Now get your SSH key content which is generated already.Open the file through editor and copy the content of the file and paste into the SSH key section in the GitLab.

Paste the content into the Key field and also you can set expiry date for the SSH key.If you left blank expiry date then this will set to never expires. See below image for your reference.

Hit the add button to save SSH key and you will get final screen as below.

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help! Stay tuned!

Best Server Option to Suit Your Business Needs

Choosing the best server for your business that meet your goals can be a nightmare. Out of
thousands of options, it’s almost become inevitable to avoid confusion. But choosing an
optimal web server that ensures security, reliability, scalability, and efficient data delivery is
very crucial because it will ensure the performance of your website. So if you want to know
which server is best for your business needs, well you are in the right place.
This choosing game is not so complicated. But you need to consider some points keeping
your business needs in mind. So in this article, I will tell you about different servers and their
features, so that you can choose one for yourself according to your needs.

What is a server?

Before diving deep into the complicated terms, lets first start with a basic one. You often have heard people saying about Server fail, server down, server not found. So what exactly this server is? Well, a server can be a program or a hardware device that provides service to its clients. In this digital world, we are constantly surrounded by data. And we need something to store it. That functionality is provided by the server. The article currently you are reading is also stored on the server somewhere. Yeah, that’s true.

When you will do your research on servers and come near to a decision, your final list will contain these three names. These are:

  1. Dedicated server
  2. Virtual private server (VPS)
  3. Cloud server

Let’s discuss one by one which one is the best option for you. 

  1. Dedicated server:- A dedicated server is a physical server that is completely dedicated to a single website or hosting a single website. It is your physical box whose resources can be accessed only by you. The client has full support and control in terms of optimizing for their needs like efficiency and performance. In simple words, in dedicated hosting, you got the whole CPU as a server that contains RAM, and hard disc. In this dedicated server, you don’t have to worry about the other website crashing which can affect your website or downtime. Dedicated hosting will cost you around 7000-20000 INR per month depending on the configuration you have picked. Businesses can easily change the server’s configuration according to their needs and can add new software to meet their requirements. Everything has its pro and cons. So do it has.

The main problem with the traditional dedicated server is, if the hard drive fails, you are down if the CPU fails you are down. If the power supply goes down, you are seriously gone down. But the advanced companies which provide these physical servers, they can fix it for you under their services. But it could be hectic sometimes. And also, upgrading physical dedicated servers like increasing RAM, speed, or memory is a real pain. But don’t worry, we have two more options for you to choose from if you are not happy with this option.

2. Virtual private server (VPS):- Virtual private server is a server where multiple websites depend on the same server but with their own set of resources like RAM and memory. Unlike shared hosting, every website has its resources. Let’s take an example to make it clearer to you. Suppose you live in a building or an apartment. You have your flat. But there are many other flats present in the building. But you are using your flat and its resources wholly and other people are using their flat. Similarly, websites use a single server which is virtually divided into many parts. Flats, here are called virtual machines, the building is the whole server and the furniture of your flat is the resources like memory and RAM. It will cost you around 2000-10000 INR per month.

The disadvantages with the virtual private server are that at the end of the day you are sharing a server and you don’t have complete control over the server. Another possible risk with the virtual private network is that your service provider will not provide you with a unique IP address. You will’ be sharing your IP address with some other occupant at that server. And you should be conscious of that as well.

So VPS hosting is not for everyone. But if you are using shared hosting, and traffic on your website has increased, then you can leap to a virtual private server for better flexibility and performance.

Lastly yet importantly we have on our list is:

3.Cloud server:- Cloud server is a robust virtual set of servers that provides services and resources like any other servers but accessed remotely over the internet. In cloud server every server is connected to others, so you don’t have to worry about your data getting lost or facing the problem of downtime. In addition to that, you can configure or update your system on the go. It means if you think traffic on your website has increased and you need more space and RAM, you can easily configure it. This is one of the reasons people prefer cloud servers over others. Because you have to pay what you are using. The cloud server provides you uninterrupted communication and high security, which is the main concern of any business.

But here are some negatives of a cloud server. Since the cloud server is an internet-based model, you need to have a strong internet connection. In a cloud server, users have very limited control over the server because the cloud server is entirely managed by the service providers.

Since all the three servers have their differences. But You can choose the best option for your business by setting up your priorities and requirement. If you are a beginner at blogging, you can go with a dedicated server and VPS. Don’t go with a shared server, because you will be putting yourself at a disadvantage. Go for a cloud server if you are facing a plethora of traffic on your website and your business is going rampant.

Test APIs through Postman Step by Step

Postman is presently one of the most well-known tool utilized in API testing. It began in 2012 as a side task by Abhinav Asthana to improve API work process in testing and advancement. Programming interface represents Application Programming Interface which enables programming applications to speak with one another by means of API calls.

Application Programming interface is a characterized set of standards, which contains unmistakably characterized techniques for communication. Programming interface causes diverse programming parts to connect with one another. Programming interface testing includes testing the accumulation of APIs and checking on the off chance that they meet desires for usefulness, unwavering quality, execution, and security and returns the right reaction.

API Testing is utilized to decide if the yield is well-organized and helpful to another application or not, checks the reaction on premise of information parameter, and checks how much time the API is taking to recover and approve the information as well.

Postman allows users to set all the headers and cookies then the API expects and check out the response. Productivity can be enhance using some of the Postman features. A test in Postman is simply a JavaScript code which runs after, sending the request and a response has been received from the server.

Why use Postman for API testing

  1. Accessibility: To utilize Postman, one would simply need to sign in to their own records making it simple to access documents whenever, anyplace up to a Postman application is introduced on the PC.
  2. Use of collections: Postman gives clients a chance to make accumulations for their API calls. Every accumulation can make subfolders and different solicitations. This aides in arranging your test suites.
  3. Automation Testing: Using the Collection Runner or Newman, tests can be kept running in different cycles sparing time for tedious tests.
  4. Debugging: Postman support checks what information has been recovered making it simple to troubleshoot tests.
  5. Continuous Integration: With its capacity to help persistent mix, improvement practices are kept up.

How to use Postman

You can download and install the postman from the browser. When you open the dashboard the below window will be seen. 

How to create your first request

  1. A GET Method
  2. The auth_token query parameter whose value will be the personal API Key.

You have to enter the following details into the Postman application

  1. Select the GET Method
  2. Add the URL
  3. Click on  the “Params” to add URL query Params
  4. Fill the key value pair for auth_token query param.
  5. Then click on send and run the HTTP request.

When the request will executes successfully you will see the result appear in the window below with the information containing status code returned and the request time.

Importing Requests

You can make the process even easier by importing the requests. It is time taken process to enter all the requests to test multiple APIs. Postman has the feature of import requests directly from certain formats. You should follow the below simple steps while importing the requests.

  1. Click on import 
  2. Select the option “Paste Raw Text” and paste in the curl command text.
  3. Again click on import for importing request

Exporting requests as code

In the wake of testing and trying different things with your API in Postman, the subsequent stage would normally be to utilize it in your application. It has customer usage for its API in Ruby, Python, JavaScript, PHP, Go, and C#. In any case, on the off chance that you need to consider its API’s utilizing a custom HTTP customer in your preferred language, or in a language excluded in the API documentation, Postman has you secured. We can send out our HTTP demand into a wide range of configurations and usage.

Features and benefits of Postman

  1. Easy Syntax

It has simple syntax which helps in making the test easier to write and read.

  1. Error Handling

If error in the script occurs then only that test will fail and the other test will still run. Error will be displayed for the failed scripts.

  1. JSON Schema Validation

Client can approve reactions again a particular JSON mapping by utilizing declaration as response.body.should.have.schema

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help! Stay tuned!

Amazon SES SMTP in PHPMailer: Send Email Using AWS SES and PHPMailer in CI

With having a large number of features, amazon become a popular hosting service provider. In this tutorial we will see how to send Email using AWS SES and PHPMailer with SMTP Configuration. We will see step by step this implementation.

Get SMTP Credentials from AWS SES:

To get SMTP Credentials from Amazon SES you need to do following simple things:

  • Login to your amazon console account.To login click here Sign in to AWS Account.
  • Go to the Simple Email Service Section(You can search it from search bar by typing Simple Email Service).
  • Select SMTP Settings from left sidebar menu.
  • Click on “Create My SMTP Credential” button to generate SMTP credentials.
  • Copy username and password to use in your application.

Setting up AWS SES SMTP Credentials in PHPMailer:

To use SMTP  in PHPMailer .

$mail->isSMTP();
To set from(Sender) Email Address.
$mail->setFrom('info@techalltype.com', 'Techalltype');
Replace info@techalltype.com with your “From” address. This address must be verified with Amazon SES. You can verify domain name on AWS SES. After verifying you will be able to send email from any email ID which is ended with this domain.
To add recipient address in PHPMailer.
$mail->addAddress('any@techalltype.com', 'Recepient Name');
Replace any@techalltype.com with a “To” address. You can include several address to send email to multiple recipients.
To set AWS SES SMTP user name in PHPMailer.
$mail->Username = 'Your AWS SMTP User Name';
Replace smtp_username with your Amazon SES SMTP user name.
To set AWS SES SMTP Password in PHPMailer.
$mail->Password = 'Your AWS SES SMTP Password';
Replace SMTP password with your Amazon SES SMTP password.
To setup configuration.
$mail->addCustomHeader('X-SES-CONFIGURATION-SET', 'ConfigSet');
If you do not want to use a configuration set, comment or remove above line.
To set Host Name.
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
If you’re using Amazon SES in a region other than US West (Oregon),         replace email-smtp.us-east-1.amazonaws.com with the Amazon SES SMTP endpoint in the appropriate region.

Setting up PHPMailer Class in Codeigniter Application:

After generating SMTP Credentials now we will see how to Configure PHPMailer Class with AWS SES SMTP Credentials in our Codeigniter Application. To install PHPMailer inside of Codeigniter Application we will use composer.Please find below the command to install PHPMailer using composer.

$ composer require phpmailer/phpmailer

After installing, you will get a vendor folder inside project root folder.

Setup Composer Autoload for PHPMailer Class:

You need to set vendor directory path inside application/config/config.php.

$config['composer_autoload'] = 'vendor/autoload.php';

Creating Controller(Amazon SES SMTP Setup) and Complete Code:

Create a controller named AwsSesSMTPController.php and use PHPMailer class inside controller.Please find below the complete code of controller.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use PHPMailer\PHPMailer\PHPMailer;
class Welcome extends CI_Controller {
public function index()
{
$mail = new PHPMailer;
$mail->isSMTP();
$mail->setFrom('info@techalltype.com', 'Techalltype');
$mail->addAddress('any@techalltype.com', 'Recepient Name');
$mail->Username = 'Your AWS SMTP User Name';
$mail->Password = 'Your AWS SES SMTP Password';
$mail->addCustomHeader('X-SES-CONFIGURATION-SET', 'ConfigSet');
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
$mail->Subject = 'Amazon SES test using PHPMailer';
$mail->isHTML(true);
$mail->Body = '<h1>Email Test</h1> This email was sent through the Amazon SES SMTP interface using the PHPMailer class.';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

/* The alternative email body; this is only displayed when a recipient
opens the email in a non-HTML email client. The \r\n represents a
line break.*/
$mail->AltBody = "Email Test\r\nThis email was sent through the Amazon SES SMTP interface using the PHPMailer class.";
if(!$mail->send()) {
echo "Email not sent. " , $mail->ErrorInfo , PHP_EOL;
} else {
echo "Email sent!" , PHP_EOL;
}
}
}
Note: If your account is still in the sandbox, this address must be verified. Also note that you can include several addAddress() lines to send email to multiple recipients.
Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help! Stay tuned!