我正在尝试使用oauth2-client的oauth2-client。
我通过作曲家安装了软件包,它在我的根部使用联赛软件包创建了一个供应商文件夹。然后,我将其复制到我的应用程序/thix_party/供应商文件夹中。
在我的控制器中,我正在尝试这样做:
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class APl extends MY_Controller
{
public function __construct()
{
parent::__construct();
// Force SSL
$this->force_ssl();
// Form and URL helpers always loaded (just for convenience)
$this->load->helper('url');
$this->load->helper('form');
//Load Libraries
$this->load->library('managers/NameManager');
$this->load->library('managers/BreadcrumbManager');
}
public function aPLogin() {
$provider = new LeagueOAuth2ClientProviderGenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
}
}
在我的配置文件中,我尝试放置此代码:
$config['composer_autoload'] = TRUE;
require FCPATH . 'third_partyvendorautoload.php';
,在我的index.php文件中看起来像这样:
require FCPATH . 'third_partyvendorautoload.php';
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once BASEPATH.'core/CodeIgniter.php';
我尝试更改FCPATH要求:
require_once APPPATH.'third_partyvendorautoload.php';
也尝试了:
include_once BASEPATH.'../application/third_party/vendor/autoload.php';
然后我要么得到:
Fatal error: require(): Failed opening required 'D:wampwwwcodeigniterthird_partyvendorautoload.php' (include_path='.;C:phppear') in D:wampwwwcodeigniterindex.php on line 311
或
Message: Class 'LeagueOAuth2ClientProviderGenericProvider' not found
我只是想向您展示使用您要使用的软件包所花费的内容。我设置了一个新的Codeigniter安装,然后进行以下...
首先,我将Config/config的作曲家自动加载:
$config['composer_autoload'] = TRUE;
接下来,一个最小的作曲家。 来自命令行: 然后,在我的欢迎控制器中,我将其放置: 当我在浏览器中访问/Welcome/oauth_test时,我会得到: 因此,您所做的一切都不是必需的。如果是我,我想我会尝试删除整个供应商目录,然后重试。另外,我注意到您在Windows上,尽管我认为这应该不重要,但我在Linux上(这是大多数Web代码的生产环境)。{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new LeagueOAuth2ClientProviderGenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
object(LeagueOAuth2ClientProviderGenericProvider)#15 (17) {
["urlAuthorize":"LeagueOAuth2ClientProviderGenericProvider":private]=>
string(51) "http://brentertainment.com/oauth2/lockdin/authorize"
["urlAccessToken":"LeagueOAuth2ClientProviderGenericProvider":private]=>
string(47) "http://brentertainment.com/oauth2/lockdin/token"
["urlResourceOwnerDetails":"LeagueOAuth2ClientProviderGenericProvider":private]=>
string(50) "http://brentertainment.com/oauth2/lockdin/resource"
["accessTokenMethod":"LeagueOAuth2ClientProviderGenericProvider":private]=>
NULL
["accessTokenResourceOwnerId":"LeagueOAuth2ClientProviderGenericProvider":private]=>
NULL
["scopes":"LeagueOAuth2ClientProviderGenericProvider":private]=>
NULL
["scopeSeparator":"LeagueOAuth2ClientProviderGenericProvider":private]=>
NULL
["responseError":"LeagueOAuth2ClientProviderGenericProvider":private]=>
string(5) "error"
["responseCode":"LeagueOAuth2ClientProviderGenericProvider":private]=>
NULL
["responseResourceOwnerId":"LeagueOAuth2ClientProviderGenericProvider":private]=>
string(2) "id"
["clientId":protected]=>
string(7) "demoapp"
["clientSecret":protected]=>
string(8) "demopass"
["redirectUri":protected]=>
string(37) "http://example.com/your-redirect-url/"
["state":protected]=>
NULL
["grantFactory":protected]=>
object(LeagueOAuth2ClientGrantGrantFactory)#16 (1) {
["registry":protected]=>
array(0) {
}
}
["requestFactory":protected]=>
object(LeagueOAuth2ClientToolRequestFactory)#17 (0) {
}
["httpClient":protected]=>
object(GuzzleHttpClient)#18 (1) {
["config":"GuzzleHttpClient":private]=>
array(7) {
["handler"]=>
object(GuzzleHttpHandlerStack)#19 (3) {
["handler":"GuzzleHttpHandlerStack":private]=>
object(Closure)#26 (2) {
["static"]=>
array(2) {
["default"]=>
object(Closure)#24 (2) {
["static"]=>
array(2) {
["default"]=>
object(GuzzleHttpHandlerCurlMultiHandler)#20 (5) {
["factory":"GuzzleHttpHandlerCurlMultiHandler":private]=>
object(GuzzleHttpHandlerCurlFactory)#21 (2) {
["handles":"GuzzleHttpHandlerCurlFactory":private]=>
array(0) {
}
["maxHandles":"GuzzleHttpHandlerCurlFactory":private]=>
int(50)
}
["selectTimeout":"GuzzleHttpHandlerCurlMultiHandler":private]=>
int(1)
["active":"GuzzleHttpHandlerCurlMultiHandler":private]=>
NULL
["handles":"GuzzleHttpHandlerCurlMultiHandler":private]=>
array(0) {
}
["delays":"GuzzleHttpHandlerCurlMultiHandler":private]=>
array(0) {
}
}
["sync"]=>
object(GuzzleHttpHandlerCurlHandler)#22 (1) {
["factory":"GuzzleHttpHandlerCurlHandler":private]=>
object(GuzzleHttpHandlerCurlFactory)#23 (2) {
["handles":"GuzzleHttpHandlerCurlFactory":private]=>
array(0) {
}
["maxHandles":"GuzzleHttpHandlerCurlFactory":private]=>
int(3)
}
}
}
["parameter"]=>
array(2) {
["$request"]=>
string(10) ""
["$options"]=>
string(10) ""
}
}
["streaming"]=>
object(GuzzleHttpHandlerStreamHandler)#25 (1) {
["lastHeaders":"GuzzleHttpHandlerStreamHandler":private]=>
array(0) {
}
}
}
["parameter"]=>
array(2) {
["$request"]=>
string(10) ""
["$options"]=>
string(10) ""
}
}
["stack":"GuzzleHttpHandlerStack":private]=>
array(4) {
[0]=>
array(2) {
[0]=>
object(Closure)#27 (1) {
["parameter"]=>
array(1) {
["$handler"]=>
string(10) ""
}
}
[1]=>
string(11) "http_errors"
}
[1]=>
array(2) {
[0]=>
object(Closure)#28 (1) {
["parameter"]=>
array(1) {
["$handler"]=>
string(10) ""
}
}
[1]=>
string(15) "allow_redirects"
}
[2]=>
array(2) {
[0]=>
object(Closure)#29 (1) {
["parameter"]=>
array(1) {
["$handler"]=>
string(10) ""
}
}
[1]=>
string(7) "cookies"
}
[3]=>
array(2) {
[0]=>
object(Closure)#30 (1) {
["parameter"]=>
array(1) {
["$handler"]=>
string(10) ""
}
}
[1]=>
string(12) "prepare_body"
}
}
["cached":"GuzzleHttpHandlerStack":private]=>
NULL
}
["allow_redirects"]=>
array(5) {
["max"]=>
int(5)
["protocols"]=>
array(2) {
[0]=>
string(4) "http"
[1]=>
string(5) "https"
}
["strict"]=>
bool(false)
["referer"]=>
bool(false)
["track_redirects"]=>
bool(false)
}
["http_errors"]=>
bool(true)
["decode_content"]=>
bool(true)
["verify"]=>
bool(true)
["cookies"]=>
bool(false)
["headers"]=>
array(1) {
["User-Agent"]=>
string(56) "GuzzleHttp/6.2.1 curl/7.47.0 PHP/7.0.22-0ubuntu0.16.04.1"
}
}
}
}