Php Woocommerce rest api-操作超时
因此,我需要定期(至少每天)从我的wordpress/woocommerce中抽取所有客户,并将其插入到一个集中数据库中。我可以连接到api而没有任何问题,但似乎设置了任意速率限制 当我运行以下代码时:Php Woocommerce rest api-操作超时,php,wordpress,woocommerce,wordpress-rest-api,woocommerce-rest-api,Php,Wordpress,Woocommerce,Wordpress Rest Api,Woocommerce Rest Api,因此,我需要定期(至少每天)从我的wordpress/woocommerce中抽取所有客户,并将其插入到一个集中数据库中。我可以连接到api而没有任何问题,但似乎设置了任意速率限制 当我运行以下代码时: for ($i = 1; $i < 100; $i++) { $data = array( 'per_page' => 30, 'orderby' => 'registered_date', 'order' =>
for ($i = 1; $i < 100; $i++) {
$data = array(
'per_page' => 30,
'orderby' => 'registered_date',
'order' => 'desc',
'page' => $i,
);
$woocommerce = new Client(
'https://example.com',
'ck_xxx',
'cs_xxx',
[
'wp_api' => true,
'version' => 'wc/v2',
]
);
try {
$customers = $woocommerce->get('customers', $data);
}
catch(HttpClientException $e) {
$err = $e->getMessage();
}
foreach($customers as $customer){
$SystemID = $customer->id;
$CustomerEmail = $customer->email;
$CustomerFirstName = $customer->first_name;
$CustomerLastName = $customer->last_name;
$CustomerRoleName = $customer->role;
$UserName = $customer->username;
$SourceSystemCreatedDate = $customer->date_created;
$SourceSystemLastEdit = $customer->date_modified;
$RoleUUID = SelectCustomerRole($CustomerRoleName)['CustomerRoleUUID'];
$Active = 1;
$CustomerUUID = InsertCustomer($SourceSystemUUID, $SystemID, $CustomerEmail, $CustomerFirstName, $CustomerLastName, $Active, $SourceSystemCreatedDate, $SourceSystemLastEdit, $UserName, $RoleUUID);
print_r($CustomerUUID);
}
}
将
超时
选项添加到客户端选项:
$woocommerce = new Client(
'https://example.com',
'ck_xxx',
'cs_xxx',
[
'wp_api' => true,
'version' => 'wc/v2',
'timeout' => 400 // curl timeout
]
这将在内部设置时间,并将
超时
选项添加到客户端选项中:
$woocommerce = new Client(
'https://example.com',
'ck_xxx',
'cs_xxx',
[
'wp_api' => true,
'version' => 'wc/v2',
'timeout' => 400 // curl timeout
]
这将在内部设置时间以及