【发布时间】:2017-02-21 13:50:01
【问题描述】:
我是 BigCommerce 以及插件的完全菜鸟。最近还计划开发一款一键式应用程序,任何商店的用户都可以在他们的商店中安装该应用程序。我对php有很好的了解。所以,我可以编码,但不知道插件的流程。 要创建一个草稿应用程序,我访问了 devtools.bigcommerce.com 并创建了一个应用程序,将 Auth Callback url 定义为 https://amanangira.com/bCommerce/oauth.php 并将回调网址加载为https://amanangira.com/bCommerce/callBack.php
在 oauth.php 中我插入了以下代码
<?php
$data = array( "client_id" => "123456789",
"client_secret" => "123456789",
"redirect_uri" => "https://amanangira.com/bCommerce/callBack.php",
"grant_type" => "authorization_code",
"code" => $_GET["code"], "scope" => $_REQUEST["scope"], "context" => $_GET["context"], );
$postfields = http_build_query($data);
$ch = curl_init();
//$url = "https://api.bigcommerce.com/stores/wky4s3lfef/v3/";
$url = "https://login.bigcommerce.com/oauth2/token";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
curl_close ($ch);
$obj = json_decode($output);
var_dump($obj);
?>
现在,每当我在我的测试商店中安装应用程序时,它都会显示以下内容。
/var/www/html/angira/bCommerce/oauth.php:37: 对象(stdClass)[3] 公共'错误'=>字符串'redirect_uri_mismatch'(长度= 21) public 'error_description' => string '参数 redirect_uri 与注册的 URI 不匹配' (length=52)
请以尽可能简单的方式帮助解决上述问题。 谢谢。
【问题讨论】:
标签: php api plugins oauth bigcommerce