YesMail v2 API:400使用PHP进行cURL请求时出错

时间:2015-07-29 21:45:41

标签: php api rest curl

我正在尝试从MMID获取定位但返回以下错误。我知道我的凭据是正确的,并且多次对文档进行梳理。以下响应中的“appTesting”是我的应用程序在YesMail中的名称

INFO: HTTP Response Code was: 400 INFO: Response Follows... HTTP/1.1 400 Bad Request Access-Control-Allow-Origin: * Api-User: appTesting Content-Type: application/json Date: Wed, 29 Jul 2015 21:38:54 GMT Tracking-Id: f257bd75-47bb-40e7-a12c-5a45a042cbac X-Content-Type-Options: nosniff transfer-encoding: chunked Connection: keep-alive {"status":400,"message":"Could not open Hibernate Session for transaction; nested exception is java.lang.IllegalStateException: Cannot determine target DataSource for lookup key [appTesting]"}

我有点难过。我做错了什么?

<?php
$mmid = 'mmid';
$api_user = "appTesting";
$api_key = "api key";

$ym_api_url = 'https://api.yesmail.com/v2/masters/';

$curl_hdl = curl_init();

$curl_options = array(
CURLOPT_VERBOSE => 1,           
CURLOPT_HEADER => TRUE,               
CURLOPT_HTTPHEADER => array("Api-User: $api_user", "Api-Key: $api_key", "Accept: application/json",),
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,   
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS, 
CURLOPT_RETURNTRANSFER => 1,     
CURLOPT_URL => $ym_api_url.$mmid.'/target',        
);

curl_setopt_array($curl_hdl, $curl_options);

$response = curl_exec($curl_hdl);

$http_response_code = curl_getinfo($curl_hdl, CURLINFO_HTTP_CODE);

curl_close($curl_hdl);

echo PHP_EOL . "INFO: HTTP Response Code was: " . $http_response_code . PHP_EOL;

if ( $response === false )
{
echo PHP_EOL . "ERROR: curl_exec() has failed." . PHP_EOL;
}
else
{
echo PHP_EOL . "INFO: Response Follows..." . PHP_EOL;
echo PHP_EOL . $response;
}
echo "<br/><br/>API USER: ".$api_user."<br/><br/>API KEY: ".$api_key;
?>

0 个答案:

没有答案