致命错误:找不到"OAuth"类 [英] Fatal error: Class 'OAuth' not found in

查看:97
本文介绍了致命错误:找不到"OAuth"类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到LinkedIn API,但是每次尝试访问它时,都会出现以下错误:

I'm trying to connect to the LinkedIn API but everytime I try to access it I get the following error:

致命错误:在/home/vhosts/*/test.php中找不到类"OAuth" 第8行

Fatal error: Class 'OAuth' not found in /home/vhosts/*/test.php on line 8

我在000WebHost上使用了免费服务器,并且我读到免费服务器有时不支持OAuth.我已经在另一台免费服务器上尝试过,但收到了相同的错误消息,所以我的问题是如何检查服务器是否支持使用OAuth?

I'm using a free server on 000WebHost and I've read that free servers sometimes don't support OAuth. I've tried it on another free server and I get the same error message, so my question is how can I check whether the server supports the use of OAuth?

这是我的代码:

// Fill the keys and secrets you retrieved after registering your app
$oauth = new OAuth("abcd123456", "efgh987654");
$oauth->setToken("abcd1234-efgh987-9988", "9876abcd-123asdf-1122");

$params = array();
$headers = array();
$method = OAUTH_HTTP_METHOD_GET;

// Specify LinkedIn API endpoint to retrieve your own profile
$url = "http://api.linkedin.com/v1/people/~";

// By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply       specify the format in your call
// $url = "http://api.linkedin.com/v1/people/~?format=json";

// Make call to LinkedIn to retrieve your own profile
$oauth->fetch($url, $params, $method, $headers);

echo $oauth->getLastResponse();

这些键只是被《 LikedIn开发人员入门指南》中的键所代替.

The keys are just replaced with the ones on the LikedIn Developers Getting Started Guide.

预先感谢您的帮助.

推荐答案

OAuth是PECL扩展,必须将其编译为PHP或编译为扩展.

OAuth is a PECL extension it must be compiled into PHP or compiled as an extension.

  • http://us3.php.net/manual/en/oauth.installation.php
  • http://pecl.php.net/package/oauth

默认情况下,大多数服务器都不会安装它,因为它并不是每个人都可能会使用的东西.您可以要求主机安装它,或者如果像我一样使用CGI,是否可以在服务器上编译它.如果您运行phpinfo();并寻找"OAuth"一词,如果有的话,它将显示出来,否则就没有.

Most servers will not have it by default since it really is not something everyone would likely use. You can ask your host to either install it or if you have the ability compile it on server if using CGI as I did. If you run phpinfo(); and look for the word OAuth it will show up if you have it, otherwise you don't.

更新:使用 https://github.com/Lusitanian/PHPoAuthLib而不是PECL.

Update: Use https://github.com/Lusitanian/PHPoAuthLib instead of a PECL.

这篇关于致命错误:找不到"OAuth"类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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