Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php GoCardless API-列表订阅_Php_Api_Gocardless - Fatal编程技术网

Php GoCardless API-列表订阅

Php GoCardless API-列表订阅,php,api,gocardless,Php,Api,Gocardless,我正在使用GoCardless文档尝试列出客户的所有订阅 正如您在下面看到的,我已经按照说明进行了操作,但是当我运行此脚本时,没有显示任何内容-有人知道我可能做错了什么吗 require 'vendor/autoload.php'; $client = new \GoCardlessPro\Client(array( 'access_token' => 'XXXXXx', 'environment' => \GoCardlessPro\Environment::LI

我正在使用GoCardless文档尝试列出客户的所有订阅

正如您在下面看到的,我已经按照说明进行了操作,但是当我运行此脚本时,没有显示任何内容-有人知道我可能做错了什么吗

require 'vendor/autoload.php';    
$client = new \GoCardlessPro\Client(array(
  'access_token' => 'XXXXXx',
  'environment'  => \GoCardlessPro\Environment::LIVE
));

     $client->subscriptions()->list([
  "params" => ["customer" => "CU000R3B8512345"]
]);

单独调用方法没有任何作用。它将执行给定的方法,但它不会自己在浏览器屏幕上打印任何内容

正如GoCardless的API文档所述,调用$client->subscriptions->list将返回一个对象。所以你需要对这个结果做点什么。这是什么,我不知道,因为这是应用程序的业务逻辑,只有您知道


单独调用方法没有任何作用。它将执行给定的方法,但它不会自己在浏览器屏幕上打印任何内容

正如GoCardless的API文档所述,调用$client->subscriptions->list将返回一个对象。所以你需要对这个结果做点什么。这是什么,我不知道,因为这是应用程序的业务逻辑,只有您知道


使用GoCardles进行分页:

function AllCustomers($client)
{
    $list = $client->customers()->list(['params'=>['limit'=>100]]);
    $after = $list->after;
    // DO THINGS
    print_r($customers);

    while ($after!="")
    {
        $customers = $list->records;
        // DO THINGS
        print_r($customers);
        
        // NEXT
        $list = $client->customers()->list(['params'=>['after'=>$after,'limit'=>100]]);
        $after = $list->after;
    }
}

使用GoCardles进行分页:

function AllCustomers($client)
{
    $list = $client->customers()->list(['params'=>['limit'=>100]]);
    $after = $list->after;
    // DO THINGS
    print_r($customers);

    while ($after!="")
    {
        $customers = $list->records;
        // DO THINGS
        print_r($customers);
        
        // NEXT
        $list = $client->customers()->list(['params'=>['after'=>$after,'limit'=>100]]);
        $after = $list->after;
    }
}

使用类似邮递员的方法来验证您的请求是否应该返回data@Kevin对不起,“邮递员”是什么?你只是在执行命令。你没有返回或打印任何内容,所以不会显示任何内容。@MartinBean-我该怎么做Martin?我试着将整行代码转换成一个变量并打印出来,但也失败了$result=$client->subscriptions->list[…是的,仅调用该方法不会显示任何内容。您需要对结果进行处理。请使用类似postman的方法验证您的请求是否应返回data@Kevin对不起,什么是“邮递员”?您只是在执行一个命令。您没有返回或打印任何内容,所以不会显示任何内容。@MartinBean-我该怎么做呢t Martin?我试着将整行代码转换成一个变量并打印出来,但也失败了$result=$client->subscriptions->list[…是的,仅调用该方法不会显示任何内容。您需要对结果做一些处理。@Designer除了Martin放置的注释外,您是否在foreach循环中放置了任何内容?它显示了可捕获的致命错误:GoCardlessPro\Core\ListResponse类的对象无法转换为字符串i@Designer-echo;您将看到结果!尝试一个print_r$记录;它将向您显示对象的外观,这样您就可以使用实际的properties@Designer有几次有人说,调用该方法将返回一个对象。它不会在屏幕上打印任何内容。您必须对返回的对象执行某些操作!@Designer您添加了任何内容吗ide foreach循环而不是Martin放置的注释?它显示了可捕获的致命错误:GoCardlessPro\Core\ListResponse类的对象无法转换为字符串i@Designer-echo;您将看到结果!尝试打印$r记录;该记录将显示对象的外观,以便您可以使用实际的properties@Designer一对现在很多时候都说调用该方法将返回一个对象。它不会在屏幕上打印任何内容。你必须对返回的对象做些什么!