easy solution web : OOPS in PHP
LIFE HACKS PHP

Install PHP OAuth in windows to enable OAuth Authentication

 

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

echo phpinfo();

Try to find OAuth Configuration

OAuth configuration

Now if you already have this configuration enabled then you don’t need to do anything to enable OAuth configuration.

If not,

  1. go to url : http://windows.php.net/downloads/pecl/releases/oauth/1.2.3/
  2. Then download the suitable version of OAuth according to PHP version.
  3. Open the folder and find php_oauth.dll file.
  4. Now copy this file and put it in  “[WAMP_LOCATION]\bin\php\php7.0.23\ext”
  5. We have added this dll. So that PHP will be able to get the definition of OAuth class defined in PHP.
  6. Now open php,ini file

location php.ini file

 

Now open this file and below-mentioned code at the end of the file

extension=php_oauth.dll

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
  1. PHP TRAITS
  2. PHP ENCAPSULATION