You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Curl和PHP向Blinksky支付API POST数据返回404错误如何解决

问题诊断

你收到404错误的核心原因是请求的URL不匹配官方接口要求:

  • 官方明确要求订单接口的请求路径为 POST /send,基础URI拼接后完整请求地址应为 https://api.blinksky.com/api/v1/send
  • 你现有代码中的请求URL仅写了基础URI https://api.blinksky.com/api/v1,遗漏了末尾的/send路径,因此服务端无法找到对应资源返回404。
修正后的PHP代码
// 仅需修改第一行的请求URL,其余代码无需调整
$url = "https://api.blinksky.com/api/v1/send";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);

$post ='{
 "gift": {
      "action": "order",
      "apikey": "my-api-key-goes-here",
      "sender": "Luxury Automotive Inc.",
      "from": "17705551xxxxxxx",
      "dest": "16150001xxxxxxx",
      "code": "62",
      "amount": 100,
      "postal": "90211",
      "msg": "Thanks for the Gift!",
      "reference": "G62-786",
      "handle_delivery": false
    }
}';


curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json'
));  

curl_setopt($ch,CURLOPT_CUSTOMREQUEST,'POST');
curl_setopt($ch,CURLOPT_POSTFIELDS, $post);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

curl_close($ch);

var_dump($response);
print_r($response);
额外注意事项
  • 正式上线时建议将CURLOPT_SSL_VERIFYPEER和CURLOPT_SSL_VERIFYHOST调整为开启状态,避免出现安全风险
  • 代码中的apikey注意不要泄露,避免被盗用产生损失

内容的提问来源于stack exchange,提问作者Nancy Moore

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.11 20:09:03