tag:help.lighthouseapp.com,2008-09-20:/discussions/api-developers/12-issues-with-apiLighthouse: Discussion 2011-04-07T05:34:23Ztag:help.lighthouseapp.com,2008-09-20:Comment/105942007-08-09T15:17:21Z2009-06-20T20:55:57ZIssues with API<div><p>Hello,</p>
<p>I was wondering if someone could help. I'm trying to use PHP to
add a new ticket, however I just keep getting <nil-classes
type="array"/>. Here's my code...</p>
<p>$toLog .= 'Date: '.date('r')."\n\n"; $toLog .= 'URL:
'.$<em>SERVER["HTTP_HOST"].$</em>SERVER["REQUEST_URI"]."\n\n";
$toLog .= $errorMsg."\n";</p>
<p>// Send to lighthouse $base =
'http://accountname.lighthouseapp.com/projects/{project#}/tickets.xml';</p>
<p>$params = array('_token' => 'abc123', 'body' => $toLog,
'state' => 'new', 'title' => 'Error from website' );</p>
<p>foreach ($params as $key => $value) { $query_string .=
"$key=" . urlencode($value) . "&"; }</p>
<p>$url = "$base?$query_string";</p>
<p>$c = curl_init($url); curl_setopt($c, CURLOPT_RETURNTRANSFER,
1); $xml = curl_exec($c); curl_close($c); echo $xml;</p>
<p>Any thoughts/help would be VERY appreciated.</p></div>techbitstag:help.lighthouseapp.com,2008-09-20:Comment/105942007-08-09T15:55:15Z2009-06-20T20:55:57ZIssues with API<div><p>You need to post XML to the <a href=
"http://lighthouseapp.com/api/tickets">API</a> for this to work.
Something like:</p>
<pre>
blah blah
blah blah
</pre>
<p>Perhaps you could use something like <a href=
"http://us3.php.net/simplexml">simplexml</a> to come up with a php
equivalent to ActiveResource?</p></div>Rick