<?php // demo/temp_mattia.php
/**
* Consume a RESTful API
*
* https://stackoverflow.com/questions/45422567/timekit-curl-and-php
*/
error_reporting(E_ALL);
echo '<pre>';
$url = 'https://api.timekit.io/v2/calendars';
$user = '[email protected]';
$pass = 'nvHfRSlhvsnlg4rS7Wt28Ty47qdgegwSu3YK7hPW';
// PREPARE THE CURL CALL
$curl = curl_init();
// SET THE CURL OPTIONS - SEE http://php.net/manual/en/function.curl-setopt.php
curl_setopt($curl, CURLOPT_URL, $url );
curl_setopt($curl, CURLOPT_TIMEOUT, 3 );
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_USERPWD, "$user:$pass");
// GET GOOD ERROR MESSAGES
curl_setopt($curl, CURLOPT_VERBOSE, TRUE );
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE );
// IF USING SSL, THIS INFORMATION IS IMPORTANT -- UNDERSTAND THE SECURITY RISK!
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT );
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2 ); // DEFAULT
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1 ); // DEFAULT
// RUN THE CURL REQUEST AND GET THE RESULTS
$resp = curl_exec($curl);
$errno = curl_errno($curl);
$error = curl_error($curl);
$info = curl_getinfo($curl);
curl_close($curl);
// SHOW WHAT CAME BACK
var_dump($resp, $errno, $error, $info);
我已經改變了我的證件,但沒有運氣。我有這個錯誤:「字符串(56)」請求的URL返回錯誤:405方法不允許「」。我所需要的是具有這裏描述的api_token http://developers.timekit.io/docs/graphs-reference#section-client-side-authentication –