Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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 邮戳API不起作用-“;禁止错误“;_Php_Api_Restapi_Postmates - Fatal编程技术网

Php 邮戳API不起作用-“;禁止错误“;

Php 邮戳API不起作用-“;禁止错误“;,php,api,restapi,postmates,Php,Api,Restapi,Postmates,我们正在为杂货店应用程序使用postmates API。我们正在使用他们的测试凭证,但我不知道如何使用它。请指导我如何进行基本API调用。我正在使用PHP。并想知道哪个是正确的API密钥来传递头。提前感谢 <?php $curl = curl_init(); $username = "1f37d2fb-****-4689-****-****57e****"; // sandbox key from postmates developer account $passwo

我们正在为杂货店应用程序使用postmates API。我们正在使用他们的测试凭证,但我不知道如何使用它。请指导我如何进行基本API调用。我正在使用PHP。并想知道哪个是正确的API密钥来传递头。提前感谢

<?php

$curl = curl_init();
$username = "1f37d2fb-****-4689-****-****57e****"; // sandbox key from postmates developer account
$password = ""; // left this blank, as per the doc

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.postmates.com/v1/customers/my-customer-key/delivery_quotes',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('pickup_address' => '76 9th Ave, New York, NY','dropoff_address' => '76 9th Ave, New York, NY'),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Basic Y2YyZjJkNmQtYTMxNC00NGE4LWI2MDAtNTA1M2MwYWYzMTY1Og==' // Got this from postmates documentation
  ),
));
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");

$response = curl_exec($curl);

curl_close($curl);
echo $response;
?>

请指导我如何使用邮递api。谢谢

这是您发送到的实际URL还是您用您的密钥替换了我的客户密钥?我将用我在注册postmates开发者帐户时生成的密钥替换我的客户密钥(例如:cus_nwe****Sas)
{
    "kind": "error",
    "code": "forbidden",
    "message": "ForbiddenError"
}