【发布时间】:2020-03-14 00:58:46
【问题描述】:
我正在使用 square api 使用以下代码搜索我的订单:
require '../connect-php-sdk-master/autoload.php';
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('MY_AUTH_CODE');
//settings for the searchOrders
$searchOrdersSettings = ([
'location_ids'=>['MY_LOCATION_ID']
]);
$apiInstance = new SquareConnect\Api\OrdersApi();
$body = new \SquareConnect\Model\SearchOrdersRequest($searchOrdersSettings); // \SquareConnect\Model\SearchOrdersRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
$result = $apiInstance->searchOrders($body);
/* echo '<pre>';
print_r($result);
echo '<pre>'; */
} catch (Exception $e) {
echo 'Exception when calling OrdersApi->searchOrders: ', $e->getMessage(), PHP_EOL;
}
我想设置 created_at 开始和结束日期,但我不知道如何创建“包含要为请求 POST 的字段的对象”。谁能帮帮我?
【问题讨论】:
-
new \SquareConnect\Model\SearchOrdersRequest($searchOrdersSettings);根据您传递给此构造函数调用的参数数组的内容创建一个新的此类对象。所以,添加东西到$searchOrdersSettings -
@CBroe 是的。你知道我会怎么做吗?即举个例子?
标签: php square-connect