为什么我从Square服务器收到空响应?
一旦我将位置更改为其中一个测试位置,我似乎无法获得任何响应。我正在使用正确的沙盒令牌。我是否无意中遗漏了必要的信息或触发了某种错误或安全机制?在任何情况下,我都无法想象空洞的回应是恰当的。由于显而易见的原因,敏感的字符串被混淆了。
PHP
$url = 'https://connect.squareup.com/v2/locations/'.$location_id.'/transactions';
$curl_handle = curl_init($url);
$request_headers = array();
$request_headers[] = 'Content-Type: application/json';
$request_headers[] = 'Accept: application/json';
$request_headers[] = 'Authorization: Bearer '.$token;
$encodedData = json_encode($jsonData);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $encodedData);
$request_headers[] = 'Content-Length: '.strlen($encodedData);
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl_handle);
cURL请求中使用的JSON
{
"idempotency_key": "1",
"billing_address": {
"address_line_1": "123 Main Street",
"address_line_2": "",
"locality": "New York City",
"administrative_district_level_1": "NY",
"postal_code": "12345",
"country": "US"
},
"amount_money": {
"amount": 10,
"currency": "USD"
},
"delay_capture": false,
"buyer_email_address": "test@example.com",
"card_nonce": "122333444455555666666777777"
}
使用print_r(curl_getinfo($curl_handle))
我收到:
Array
(
[certinfo] => Array()
[connect_time] => 0.101375
[content_type] => application/json
[download_content_length] => 2
[filetime] => -1
[header_size] => 372
[http_code] => 200
[local_ip] => 66.198.240.51
[local_port] => 44428
[namelookup_time] => 0.009074
[pretransfer_time] => 0.392582
[primary_ip] => 74.122.190.85
[primary_port] => 443
[redirect_count] => 0
[redirect_time] => 0
[redirect_url] =>
[request_size] => 734
[size_download] => 2
[size_upload] => 492
[speed_download] => 3
[speed_upload] => 979
[ssl_verify_result] => 0
[starttransfer_time] => 0.502108
[total_time] => 0.502167
[upload_content_length] => 492
[url] => https://connect.squareup.com/v2/locations/__example__/transactions
)