API PHP Example
Hi,
I was struggling with getting the Lighthouse API to work on PHP, but I finally managed. One thing I was missing was a simple working(!) example, so I'll just share my example (for adding a ticket) with you in order to get you started (maybe it's not that elegant, but it works ;) );
$l_sUrl = "http://{your_app_name}.lighthouseapp.com/projects/{project-id}/tickets.xml";
$l_oCurl = curl_init();
curl_setopt( $l_oCurl,CURLOPT_URL, $l_sUrl );
curl_setopt( $l_oCurl, CURLOPT_USERPWD, "username:password" );
$l_sTitle = "title_here";
$l_sDescription = "description here";
$l_sXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>".
"<ticket>".
"<title>".$l_sTitle."</title>".
"<body>".$l_sDescription."</body>".
"</ticket>";
$l_sHeader = "X-LighthouseToken: {token_here}\r\n";
$l_sHeader .= "Content-type: application/xml\r\n";
$l_sHeader .= "Content-length: ".strlen( $l_sXml ) . "\r\n\n"; // Important! Two linebreaks.
$l_sHeader .= $l_sXml;
curl_setopt( $l_oCurl, CURLOPT_HTTPHEADER, array( $l_sHeader ) );
$l_oResult = curl_exec( $l_oCurl );
curl_close($l_oCurl);
Discussions are closed to public comments.
If you need help with Lighthouse please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Tiger Team on 24 Sep, 2008 04:32 PM
Will, this should go into the KB.
2 Posted by Rick on 24 Sep, 2008 04:49 PM
3 Posted by Rick on 24 Sep, 2008 04:50 PM
I'd suggest you html encode the title and description fields. If you use any raw html entities like <, it will break the XML.
4 Posted by System on 03 Dec, 2008 09:22 PM
This discussion was assigned to Will, on ticket 22.
5 Posted by bryan on 21 Apr, 2009 03:06 PM
thanks for getting me started. I found one thing missing for creating a ticket:
curl_setopt($l_oCurl, CURLOPT_POST, 1);
(Need to send the XML request as POST to create a ticket)
6 Posted by Will Duncan on 21 Apr, 2009 08:13 PM
brandi closed this discussion on 29 Jun, 2012 10:10 PM.
Tiger Team re-opened this discussion on 26 Apr, 2013 12:33 AM
Support Staff 7 Posted by Tiger Team on 26 Apr, 2013 12:33 AM
anyone following this, here is a better post for the business end of things that actually generates a valid http request o_O
Tiger Team closed this discussion on 26 Apr, 2013 12:34 AM.