无法让 Oauth PHP 扩展工作 [英] Cannot get Oauth PHP extension to work
问题描述
在尝试使用 PHP 进行 oAuth 之旅时,我正在纠结.
I''m pulling my hair out when trying to carry out an oAuth journey using PHP.
我使用的是 MAC_OSX_10.7.4/MAMP/PHP,我指向的是 MAMP 环境中的 php.
I'm using a MAC_OSX_10.7.4/MAMP/PHP and I am pointing to the php inside my MAMP environment.
我已经下载了最新的 oAuth php 扩展 1.2.2.
I have downloaded the latest oAuth php extension 1.2.2.
我跑了:
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
我添加了以下行:
extension=oauth.so
在我的 php.ini 中.但是每当我尝试运行这段简单的代码来测试 oauth 时:
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";
?>
我在我的 php 日志中收到以下错误
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
任何想法我可能做错了什么?我已经检查过 php.ini 并且它没有出现在那里.我什至删除了现有的扩展并重新添加了它们以确保我的 php.ini 正确更新.
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.
唯一让我觉得有点奇怪的是,我所有以 .so 结尾的扩展名都是 unix 可执行文件,但我的 oauth 文件是一个文档.这可能是问题吗?我添加了一个屏幕截图来显示扩展.
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.
推荐答案
我碰巧在 php 信息页面中加载了它但不起作用.
It happened with me that it is loaded in the php info page but not working.
如果列表中显示OAuth",请确保真正加载了哪些模块:
Make sure what modules are really loaded, if "OAuth" is showing in the list:
php -m
确保扩展文件.ini"加载在正确的目录中,在我的情况下它在里面
Make sure that the extension file ".ini" is loaded in the right directory, in my case it was inside
/etc/php5/conf.d/
/etc/php5/conf.d/
而不是它应该在的地方:
instead of where it is supposed to be:
/etc/php5/cli/conf.d/
/etc/php5/cli/conf.d/
然后重启apache.
Then restart apache.
这篇关于无法让 Oauth PHP 扩展工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!