Php 方API赢得';t返回位置列表-无效请求错误
这是我的密码:Php 方API赢得';t返回位置列表-无效请求错误,php,api,square,square-connect,Php,Api,Square,Square Connect,这是我的密码: // Build request URL $url = 'https://connect.squareup.com/v2/locations/'; // Build and execute CURL request $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers
// Build request URL
$url = 'https://connect.squareup.com/v2/locations/';
// Build and execute CURL request
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_ENCODING => "", // handle compressed
CURLOPT_AUTOREFERER => true, // set referrer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // time-out on connect
CURLOPT_TIMEOUT => 120, // time-out on response
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . $accessToken,
'Accept: application/json',
)
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
var_dump($content);
以下是我得到的反馈:
string(158) "{"errors":[{"category":"INVALID_REQUEST_ERROR","code":"NOT_FOUND","detail":"API endpoint for URL path `/v2/locations/` and HTTP method `GET` is not found."}]}"
我的头撞在这上面。。。我尝试使用Square SDK,但从它调用也不会返回位置列表
我已经在Square Developer仪表板上创建了一个应用程序$accessToken设置为此处列出的沙箱访问令牌 您在url的末尾添加了一个额外的
/
。您应改为使用:
$url='1!'https://connect.squareup.com/v2/locations';代码>
除此之外,你的代码工作