0

我是 php 开发人员,我将我的网站与 bluesnap 集成。我想允许用户删除他们的订阅。Bt 我不能从 curl 传递 url,bt "HTTP/1.1 403 Forbidden ....." 出现?

这是代码

$xmlToSend = ' < subscription xmlns="http://ws.plimus.com" >< /subscription ' > ';               
$url = 'https://ws.bluesnap.com/services/2/subscriptions/'.$subs_id;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml')); 
curl_setopt($ch, CURLOPT_USERPWD, $credentials);   
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlToSend);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

$result = curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HEADER_SIZE);

curl_close($ch);

如何解决这个问题?我可以通过另一种方式做到这一点,或者如何在没有 curl lib 的情况下获得另一种解决方案?

谢谢

4

2 回答 2

0

Http 错误 403错误通常意味着 - 您没有启用/需要访问服务的访问角色或 IP 地址 - 您需要联系支持人员为您正在编码的订阅授予相关角色。我看到您正在呼叫订阅 - 您需要为该呼叫启用适当的角色;如果您想取消订阅,您可能还需要考虑调用取消订阅API

于 2016-05-18T19:30:55.517 回答
0

$xmlToSend =
<subscription xmlns="http://ws.plimus.com"> <subscription-id>' . $subscription_id . '</subscription-id> <status>C</status> <underlying-sku-id>' . $skuId . '</underlying-sku-id> <shopper-id>' . $shopper_id . '</shopper-id> </subscription>;

我用于取消订阅的这种 xml 格式 $url = ' https://ws.bluesnap.com/services/2/subscriptions/ '.$subs_id; 您需要修改xml而不是链接,链接是正确的。请检查这里的链接

于 2015-11-24T11:57:58.567 回答