2017-02-20 45 views
0

我是BigCommerce以及插件的完整noob。最近计划开发一种单击应用程序,可以由任何商店的用户在其商店中安装。我有良好的手在PHP。所以,我可以编码但不知道插件的流程。 要创建的应用程序草案我去devtools.bigcommerce.com和创建应用程序定义的验证回调URL作为https://amanangira.com/bCommerce/oauth.php 和负载回调URL作为https://amanangira.com/bCommerce/callBack.php无法为BigCommerce获取oAuth令牌一次点击应用程序

在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) 公众error_description'=> string'参数redirect_uri与注册的URI不匹配'(长度= 52)

请尽量简单地与上述内容协助。 谢谢。

回答

0

经过一些打击和试验,我终于偶然发现了解决方案。这是将oauth.php中的redirect_uri更新为应用程序配置中的Auth Callback uri。

"redirect_uri" => "https://amanangira.com/bCommerce/oauth.php"