Bonanza Api:Can';无法让令牌在php中工作
我遵循提供的示例=> 我正在尝试使用以下代码对“addFixedPriceItem”进行测试:Bonanza Api:Can';无法让令牌在php中工作,php,api,Php,Api,我遵循提供的示例=> 我正在尝试使用以下代码对“addFixedPriceItem”进行测试: <?php $dev_name = "************"; $cert_name = "************"; $url = "https://api.bonanza.com/api_requests/secure_request"; $headers = array("X-BONANZLE-API-DEV-NAME: " . $dev_name
<?php
$dev_name = "************";
$cert_name = "************";
$url = "https://api.bonanza.com/api_requests/secure_request";
$headers = array("X-BONANZLE-API-DEV-NAME: " . $dev_name, "X-BONANZLE-API-CERT-NAME: " . $cert_name);
$args = array();
$post_fields = "fetchTokenRequest";
echo "Request: $post_fields <BR>";
$connection = curl_init($url);
$curl_options = array(CURLOPT_HTTPHEADER=>$headers, CURLOPT_POSTFIELDS=>$post_fields,
CURLOPT_POST=>1, CURLOPT_RETURNTRANSFER=>1); # data will be returned as a string
curl_setopt_array($connection, $curl_options);
$json_response = curl_exec($connection);
if (curl_errno($connection) > 0) {
echo curl_error($connection) . "<BR>";
exit(2);
}
$response = json_decode($json_response,true);
$token = $response['fetchTokenResponse']['authToken'];
echo "Token: $token <BR>";
$item['title'] = "My Item";
$item['price'] = 30.57;
$item['quantity'] = 1;
$item['description'] = "This item is great. Any html here.";
$item['pictureDetails']['pictureURL'] = "http://www.google.com/images/logos/ps_logo2.png";
$item['primaryCategory']['categoryId'] = 377;
$item['shippingDetails']['shippingServiceOptions']['freeShipping'] = true;
$args = array("item" => $item);
$args['requesterCredentials']['bonanzleAuthToken'] = $token;
$post_fields = "addFixedPriceItem=" . urlencode(json_encode($args));
echo "Request: $post_fields <BR>";
$curl_options2 = array(CURLOPT_HTTPHEADER=>$headers, CURLOPT_POSTFIELDS=>$post_fields,
CURLOPT_POST=>1, CURLOPT_RETURNTRANSFER=>1); # data will be returned as a string
curl_setopt_array($connection, $curl_options2);
$json_response = curl_exec($connection);
if (curl_errno($connection) > 0) {
echo curl_error($connection) . "<BR>";
exit(2);
}
curl_close($connection);
$response = json_decode($json_response,true);
$itemId= $response['addFixedPriceItemResponse']['itemId'];
echo "itemId: $itemId <BR>";
echo "Response: <BR>";
echo "<PRE>";
print_r($response);
echo "</PRE>";
?>
似乎令牌不起作用,任何有过Bonanza经验的人都可以帮忙吗?您的令牌不起作用,因为它未经验证 响应应该包括“authenticationURL”,它会转到Bonanza登录页面。从那里登录将验证登录的Bonanza用户的令牌
Token verification是指Bonanza知道您拥有Bonanza用户的权限,可以代表他们添加物品或查看他们的私人销售信息我也面临同样的问题。你有解决这个问题的办法吗?
Array
(
[ack] => Failure
[version] => 1.0beta
[timestamp] => 2015-12-23T00:11:53.000Z
[errorMessage] => Array
(
[message] => Bonapitit::TokenNotVerified
)
)