PHP OAUTH 类 api [英] PHP OAUTH class api

查看:21
本文介绍了PHP OAUTH 类 api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PHP.net 中使用 OAuth::fetch() 示例(输出代码. 我使用的鳕鱼是

I am using OAuth::fetch() example in PHP.net (Outh code. The cod i use is

<?PHP
try{
$oauth = new OAuth("consumer_key","consumer_secret",OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->setToken("access_token","access_token_secret");

$oauth->fetch("http://photos.example.net/photo?file=vacation.jpg");

$response_info = $oauth->getLastResponseInfo();
header("Content-Type: {$response_info["content_type"]}");
echo $oauth->getLastResponse();
} catch(OAuthException $E) {
 echo "Exception caught!\n";
}?>

错误信息是

致命错误:在第 3 行的 C:\wamp\www\Jesvin\MyTest1\test1.php 中找不到OAuth"类

Fatal error: Class 'OAuth' not found in C:\wamp\www\Jesvin\MyTest1\test1.php on line 3

推荐答案

您没有可用的 OAuth 类.它是一个 php 扩展而不是核心包的一部分,您需要手动将其安装到 wamp 中.首先要做的是检查扩展是否可用但未加载.

You do not have the OAuth class available to use. It is a php extension and not part of the core package, you will need to install it manually into wamp. First thing to do is check whether the extension is available but not loaded.

您的 php 扩展库类似于/path/to/wamp/php/ext(我不使用 wamp,因此您必须在 google 上搜索您的路径或在您的文件系统中查找您自己)).

Your php extension library will be something like /path/to/wamp/php/ext (i do not use wamp so you will have to google for your path or look for yourself in your filesystem).

如果您看到 oauth 扩展,您可以跳过安装 oauth,如果您不需要获得预编译的 dll,请看这里:http://downloads.php.net/pierre/ 并搜索oauth",有 2 个(不确定您应该使用哪个,所以选择一个,如果它不起作用,请尝试另一个).

If you see an oauth extension, you can skip installing oauth, if you do not you need to get a precompiled dll, look here: http://downloads.php.net/pierre/ and seach for "oauth", there are 2 (not sure which one you should use, so pick one, and if it doesnt work try the other).

下载它并将 dll 与其他 php 扩展一起粘贴到您的扩展目录中.

Download it and stick teh dll in your extensions directory along with teh other php extensions.

然后找到您的 php.ini 文件(您可以使用带有 <?php phpinfo; ?> 的文件并在浏览器中加载它以查看 php.ini 的位置).找到定义扩展的位置,然后取消注释或将此行添加到 php.ini 文件中

Then find your php.ini file (you can use a file with <?php phpinfo; ?> and load it in your browser to see where php.ini is). Find where the extensions are defined and either uncomment or add this line to your php.ini file

extension=php_oauth.dll

确保上面代码中的 dll 名称与您下载并安装到扩展文件夹中的 dll 名称相同.还要确保在此行的开头有NO 分号.

ensure the dll name in the code above is teh same as the one you downloaded and installed to the extension folder. Also make sure there is NO semi colon at the start of this line.

那应该差不多了.希望 php 能够很好地加载 DLL 并且它会工作.使用预编译的 dll 并不总是有效,但在这种情况下,它有望有效.

That should just about do it. Hopefully php will load the DLL fine and it will work. Using pre-comiled dll's doesn't always work, but in this instance it will hopefully work.

这篇关于PHP OAUTH 类 api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆