我正在尝试连接到LinkedIn API但每次我尝试访问它时都会收到以下错误:
致命错误:第8行的/ home/vhosts/* /test.php中找不到"OAuth"类
我在000WebHost上使用免费服务器,我读过免费服务器有时不支持OAuth.我已经在另一个免费服务器上尝试过,我得到了相同的错误消息,所以我的问题是如何检查服务器是否支持使用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();
Run Code Online (Sandbox Code Playgroud)
这些密钥只是替换为LikedIn Developers入门指南中的密钥.
预先感谢您的帮助.
cry*_*c ツ 10
OAuth是PECL扩展,必须编译为PHP或编译为扩展.
大多数服务器默认没有它,因为它实际上不是每个人都可能使用的东西.您可以要求您的主机安装它,或者如果您像我一样使用CGI,则可以在服务器上编译它.如果你运行phpinfo(); 如果你有它,它会显示OAuth这个词,否则你就不会.
更新:使用https://github.com/Lusitanian/PHPoAuthLib而不是PECL.