In many cases, we need to interact with APIs which having OAuth authentication to verify the request from the user. And these web services only expose data to users, once users got the authenticated token and secret key.
These authentications are used by many vendors like Twitter, Facebook to share tweets to third-party applications, there are many e-commerce applications which are using OAuth authentication to share product, orders, invoice and others details to the third-party.
How to enable classes defined in PHP to deal with OAuth Authentication?
First, let’s check if installed PHP in your system has already OAuth enabled.
So to check PHP configuration we use
Try to find OAuth Configuration
Now if you already have this configuration enabled then you don’t need to do anything to enable OAuth configuration.
- go to url : http://windows.php.net/downloads/pecl/releases/oauth/1.2.3/
- Then download the suitable version of OAuth according to PHP version.
- Open the folder and find php_oauth.dll file.
- Now copy this file and put it in “[WAMP_LOCATION]\bin\php\php7.0.23\ext”
- We have added this dll. So that PHP will be able to get the definition of OAuth class defined in PHP.
- Now open php,ini file
Now open this file and below-mentioned code at the end of the file
To see the changes, restart you wamp and check using phpinfo()
Now you will be able to find OAuth configuration setting.
Or you can also try to instantiate OAuth class in PHP
$oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
OAuth Authentication is very useful when you really don’t want others to access the API without proper authentication.
I hope you found this article useful.
Read other interesting articles