curl错误,在数组apikey上

时间:2015-03-13 10:07:26

标签: php api curl

我有这个api键数组。

<?php
/*Variables - Start*/

$apiKey = array (
'phweb' => 'm776703283-58528ee50653b191361a97c8',
'phemail' => 'm776701721-d532d1d2d020749423d80200',
);


$url = array (
'phweb' => "http://api.uptimerobot.com/getMonitors?apiKey=" . $apiKey['phweb'] . "&logs=1" . "&customUptimeRatio=1-7-30" . "&format=xml",
'phemail' => "http://api.uptimerobot.com/getMonitors?apiKey=" . $apiKey['phemail'] . "&logs=1" . "&customUptimeRatio=1-7-30" . "&format=xml",
);

/*Variables - End*/
?>

我在使用curl

时有这个
<?php
/*Check Curl if Installed - Start*/
function is_curl_installed() {
if  (in_array  ('curl', get_loaded_extensions())) {
    return true;
} else {
    return false;
}
}
/*Check Curl if Installed - End*/
/*Curl Request - Start*/
function curl_seasson($url) {
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$responseXML = curl_exec($c);
curl_close($c);

return $responseXML;
}
/*Curl Request - End*/
?>

我收到此错误(请参阅上图)

enter image description here

实际上,我正在尝试提交2 api请求(curl),你可以在我的apikey数组中看到,这可能吗?看来问题是什么?任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

您将$url变量传递给原始格式的curl_initcurl_init为URL提取一个字符串,然后传递一个数组。这应该让你开始:

foreach ($url as $apiUrl)
{
    $apiResponse = curl_seasson($apiUrl);
    var_dump($apiResponse);
}