7

I''m pulling my hair out when trying to carry out an oAuth journey using PHP.

I'm using a MAC_OSX_10.7.4/MAMP/PHP and I am pointing to the php inside my MAMP environment.

I have downloaded the latest oAuth php extension 1.2.2.

I've run:

pecl install oauth

Which came back successful, when I try to reinstall it I get:

pecl/oauth is already installed and is the same as the released version 1.2.2

I have added the line:

extension=oauth.so

in my php.ini. but whenever I try and run this simple bit of code to test out oauth:

    <?php

define("CONSUMER_KEY", "dgqcifzjqksh");
define("CONSUMER_SECRET", "73Ft6jKqe3A7sCsc");

$oauth = new OAuth(CONSUMER_KEY, CONSUMER_SECRET);

echo "oauth token" . $oauth;
$request_token_response = $oauth->getRequestToken('https://api.linkedin.com/uas/oauth/requestToken');

if($request_token_response === FALSE) {
        throw new Exception("Failed fetching request token, response was: " . $oauth->getLastResponse());
} else {
        $request_token = $request_token_response;
}

print "Request Token:\n";
printf("    - oauth_token        = %s\n", $request_token['oauth_token']);
printf("    - oauth_token_secret = %s\n", $request_token['oauth_token_secret']);
print "\n";

?>

I get the following error in my php logs

PHP Fatal error:  Class 'OAuth' not found in /Applications/MAMP/htdocs/wemustcreate/wp-content/themes/MinimalDessign/linkedinOauth.php on line 6

Any Ideas what I might be doing wrong? I've checked php.ini and it doesnt show up there. I have even removed existing extensions and re added them to make sure my php.ini was updated correctly.

The only thing I can see which stikes me as being slightly odd is that all my extensions ending with .so are all unix executable files but my oauth file is a document. could this be the problem? I have added a screenshot to show the extensions.

oauth.so as a document

Owzzz
  • 177
  • 1
  • 4
  • 15
  • Check phpinfo() and verify the install. – Matt Aug 02 '12 at 20:34
  • I've checked by echo-ing phpinfo().. How do you suggest I verify it? – Owzzz Aug 02 '12 at 20:41
  • It should show up in the output for `phpinfo()`. – Matt Aug 02 '12 at 20:44
  • Yes I dont see any reference to oauth anywhere in that view other than in the name of my php file name: "linkedinOauth.php" – Owzzz Aug 02 '12 at 20:45
  • Then the Oauth installation likely didn't work the way you thought it would. I would try uninstalling it then re-installing. Other than that, I wouldn't know what to do. :-/ – Matt Aug 02 '12 at 20:48
  • It appears to of installed as expected: `Build process completed successfully Installing '/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/oauth.so' install ok: channel://pecl.php.net/oauth-1.2.2 Extension oauth enabled in php.ini` and it's in my php.ini `extension=imap.so extension=yaz.so extension=mcrypt.so extension=gettext.so extension=pgsql.so extension=pdo_pgsql.so extension="oauth.so" extension=pdo_mysql.so` – Owzzz Aug 02 '12 at 20:58
  • I appear to be getting two errors in my logs now: `PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/oauth.so' - dlopen(/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/oauth.so, 9): no suitable image found. Did find: /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/oauth.so: mach-o, but wrong architecture in Unknown on line 0 PHP Fatal error: Class 'OAuth' not found in /path/to/file/linkedinOauth.php on line 6` – Owzzz Aug 02 '12 at 21:07
  • I found this and followed it: [Installing Pecl oauth module on mamp](http://stackoverflow.com/questions/4145789/installing-the-pecl-oauth-module-on-mamp-osx-10-6) and the oauth.so in my extensions folder now is an executable file but still no luck running my code. – Owzzz Aug 02 '12 at 21:16

1 Answers1

2

It happened with me that it is loaded in the php info page but not working.

Make sure what modules are really loaded, if "OAuth" is showing in the list:

php -m

Make sure that the extension file ".ini" is loaded in the right directory, in my case it was inside

/etc/php5/conf.d/

instead of where it is supposed to be:

/etc/php5/cli/conf.d/

Then restart apache.

Rabea
  • 1,938
  • 17
  • 26