I am trying to use Pivotal API with PHP. As the version 5 use JSON instead of XML in previous version, I tried it. Here is the code :
public function updateStory($id) {
$update = '{"name":"Here is a test"}';
$url = "https://www.pivotaltracker.com/services/v5/projects/$this->project/stories/$id";
$cmd = 'curl -H "X-TrackerToken: ' . $this->token . '" -X PUT -H "Content-Type: application/json" -d \'' . $update . '\' ' . $url;
$xml = shell_exec($cmd);
echo "<pre>";
echo $cmd;
var_dump(json_decode($xml, true));
echo "</pre>";
}
The output of this code is :
curl -H "X-TrackerToken: TOKEN" -X PUT -H "Content-Type: application/json" -d '{"name":"Here is a test"}' https://www.pivotaltracker.com/services/v5/projects/IDPROJECT/stories/IDSTORY
array (size=5)
'code' => string 'could_not_parse_body'
'kind' => string 'error'
'error' => string 'Cannot parse the JSON-encoded request body.'
'general_problem' => string 'Couldn't parse the content of the request's body.'
'possible_fix' => string 'The parser returned the following error message: lexical error: invalid char in json text.
'{name:Here is a test
(right here) ------^
'
When I execute the created command above using Cygwin, it works. Using PHP, it don't.
Does anyone knows the solution?
Actually I already tried that but it doesn't work.
Anyway, I tried to use curl API in PHP. Knowing that the url use SSL I followed this thread : http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
I generated the certificate but then when I use it with PHP curl, I have a blank page.
Using Cygwin, I have this error :
curl --cacert pivotal.crt https://www.pivotaltracker.com/services/v5/projects/1202004/stories/
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
Any solution ??