【发布时间】:2015-02-25 06:16:08
【问题描述】:
使用这个 bigcommerce Auth 回调(新 API 的一部分)让我大开眼界。 我已经尝试过常规的 PHP API 和在这里找到的最新分支 https://github.com/maetl/bigcommerce-api-php/tree/f43e652c71550f9074dbf696c740b30651110051,它应该支持 OAUTH。
我在这里使用 php 下的https://developer.bigcommerce.com/apps/callback 的演示代码开始。我已经正确设置了我的应用程序等但是我的 php 没有那个错误。下面是使用链接的 OAUTH 分支,因为原始具有此代码尝试调用的不存在的功能。
这是我的代码...
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include $_SERVER['DOCUMENT_ROOT'] . '/libraries/bigcommerce/bigcommerce.php';
use Bigcommerce\Api\Connection;
$tokenUrl = "https://login.bigcommerce.com/oauth2/token";
$connection = new Connection();
$connection->useUrlencoded();
$response = $connection->post($tokenUrl, array(
"client_id" => "#myid",
"client_secret" => "#mysecret",
"redirect_url" => "http://#myoauthurl",
"grant_type" => "authorization_code",
"code" => $request->get("code"),
"scope" => $request->get("scope"),
"context" => $request->get("context"),
));
$token = $response->access_token;
?>
这首先抱怨数组最后 3 部分的“get”,并出现这样的错误......
Notice: Undefined variable: request in /var/www/integrations/bigcommerce/oauth2.php on line 18 Fatal error: Call to a member function get() on a non-object in /var/www/integrations/bigcommerce/oauth2.php on line 18
要删除那些我手动添加的...
"code" => $_GET["code"],
"scope" => $_GET["scope"],
"context" => $_GET["context"],
通过这些更改,我得到以下错误。
Fatal error: Uncaught exception 'Bigcommerce\Api\NetworkError' with message 'failed setting cipher list' in /var/www/libraries/bigcommerce/bigcommerce.php:95 Stack trace: #0 /var/www/libraries/bigcommerce/bigcommerce.php(169): Bigcommerce\Api\Connection->handleResponse() #1 /var/www/integrations/bigcommerce/oauth.php(21): Bigcommerce\Api\Connection->post('https://login.b...', Array) #2 {main} thrown in /var/www/libraries/bigcommerce/bigcommerce.php on line 95
上面对 handleReponse() 的引用似乎与库中的 CURL 操作有关。 它还指密码列表,这是以前的问题,需要
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
我可以在此处附加正确的类以获取它们,尽管我似乎没有为这部分设置密码,因为它继续呻吟。
还有其他人在上述方面有进一步的运气或有其他想法吗?
【问题讨论】:
标签: php curl bigcommerce