dpcj40970 2015-08-25 18:18
浏览 35

获取403 Forbidden Error在创建时使用API​​在Bluesnaps上创建购物者实体

I am trying to creates a shopper entity on Bluesnaps using its API but I am unable to do that.

here is the URL: http://shimion.com/create-shopper.php?firstName=bob&lastName=Smith&email=bob.Smith@gmail.com&address1=123%20Main%20Street&address2=Apt%20K-9&city=Parkville&state=TN&country=us&phone=411-555-1212&zipcode=37027

Here is the CODE:

 function get_shopper_from_header($ch, $string) {
$firstName = htmlspecialchars($_REQUEST['firstName']);           
$lastName  = htmlspecialchars($_REQUEST['lastName']);             
$email     = htmlspecialchars($_REQUEST['email']);     
$address1  = htmlspecialchars($_REQUEST['address1']);
$address2  = htmlspecialchars($_REQUEST['address2']);
$city      = htmlspecialchars($_REQUEST['city']);
$state     = htmlspecialchars($_REQUEST['state']);
$country   = htmlspecialchars($_REQUEST['country']);
$zipCode   = htmlspecialchars($_REQUEST['zipcode']);
$phone     = htmlspecialchars($_REQUEST['phone']);
$credentials = $username.':'.$password;
$firstName = 'Bob';
$lastName = 'Smith';
$email = "bob.smith@plimus.com";
$address1 = "123 Main Street";
$address2 = "Apt K-9";
$city = "Parkville";
$state = "TN";
$country = "us";
$zipCode = "37027";
$phone = "411-555-1212";
$xmlToSend = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<shopper xmlns=\"http://ws.plimus.com\">
<shopper-info>
<shopper-contact-info>
<first-name>". $firstName ."</first-name>
<last-name>". $lastName ."</last-name>
<email>". $email ."</email>
<address1>". $address1 ."</address1>
<city>". $city ."</city>
<zip>". $zipCode ."</zip>
<country>". $country ."</country>
<state>". $state ."</state>
<phone>". $phone ."</phone>
</shopper-contact-info>
<locale>en</locale>
</shopper-info>
<web-info>
<ip>62.219.121.253</ip>
<remote-host>bzq-219-121-253.static.bezeqint.net.reinventhosting.com</remote-host>
<user-agent>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.3; .NET CLR 2.0.50727</user-agent>
<accept-language>en-us</accept-language>
</web-info>
</shopper>";
$service = 'https://sandbox.plimus.com/services/2/shoppers';
$contentType = array('Content-type: application/xml');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $service);
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlToSend);
curl_setopt($ch, CURLOPT_HTTPHEADER, $contentType);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'get_shopper_from_header');
$response = curl_exec($ch);
if ( curl_errno($ch) ) {
echo 'HTTP error code: ' . curl_errno($ch) . '<br>error-message: "' . curl_error($ch) . '"';
return;
}
if (is_numeric($shopper_id)) {
echo '<br>
A new shopper entity was created on our servers with shopper-id: '
. $shopper_id .
'<br><br>';
}
else {
echo '<br><br>
<font color="red"><b>Something went wrong!</b></font>
<br>
Server reponse:
<br><br>
<pre style="display: block; font-family: monospace; white-space: pre; margin: 1em 0px;">'
. $response .
'</pre><br>';
}
?>
  • 写回答

1条回答 默认 最新

  • duanqian2278 2015-11-24 12:05
    关注

    If you are using a it from localhost than it wont work, you will need ssl also, openssl for localhost.
    if you are using it from live you need to add ip address as your server ip address and you have you have to add that ip address in your bluesnap account too in general settings.

    评论

报告相同问题?

悬赏问题

  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测