【问题标题】:How to delete customer on stripe using PHP custom curl?如何使用 PHP 自定义 curl 删除条带上的客户?
【发布时间】:2017-08-15 09:55:31
【问题描述】:

上图是我的代码的结果。我怎样才能删除它?我不想使用库,我想在使用库之前学习如何使用 PHP curl。

<?php
function DeleteCustomer() {

    $array = array(
        'id' => 'cus_AKjDJGDrHovimg'
        );

    $ch = curl_init();
    $headers = array('Authorization: Bearer xxxxxxxxxxxxxxxxxxxxx');
    curl_setopt($ch, CURLOPT_URL,'https://api.stripe.com/v1/customers');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
   curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array));
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $output=curl_exec($ch);
    curl_close($ch);
     $output = json_decode($output,true);
    return $output;
 }

$a = DeleteCustomer();
print_r($a);

?>

感谢那些愿意回答的人。

【问题讨论】:

  • 为什么curl_setopt($ch, CURLOPT_POST, 1);??

标签: php curl stripe-payments


【解决方案1】:

我设法使用此代码删除条带客户。 :D

<?php
function DeleteCustomer() {

    $ch = curl_init();
    $headers = array('Authorization: Bearer xxxxxxxxxxxxxxxxxxxxx');
    curl_setopt($ch, CURLOPT_URL,'https://api.stripe.com/v1/customers/cus_AKjDJGDrHovimg');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($ch);
    $result = json_decode($result);
    curl_close($ch);

    return $result;

 }

$a = DeleteCustomer();
echo'<pre>';
print_r($a);

?>

【讨论】:

    猜你喜欢
    • 2017-01-11
    • 2019-01-04
    • 2021-12-31
    • 1970-01-01
    • 2021-08-07
    • 2014-05-02
    • 1970-01-01
    • 1970-01-01
    • 2012-08-30
    相关资源
    最近更新 更多