<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using the Basecamp PHP Wrapper</title>
	<atom:link href="http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/</link>
	<description>A Developer with too little time.</description>
	<lastBuildDate>Sun, 18 Sep 2011 17:38:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Dan</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-30785</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 17 Jun 2008 09:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-30785</guid>
		<description>Hi Aaron, thanks for the response.  it turns out that the delete_message function needs to be altered slightly.  There needs to be a body to the post or it will return a redirect.

I&#039;ve posted the code changed here: http://forum.37signals.com/basecamp/forums/8/topics/6420?page=1#posts-22139

This

// Delete the message with the given id.
    function delete_message($message_id) {
        return $this-&gt;hook(&quot;/msg/delete/{$message_id}&quot;,&quot;post&quot;);
    }


needs to be changed to something like this 

// Delete the message with the given id.
    function delete_message($message_id) {
        $request[&#039;post&#039;] = &quot;delete&quot;;
        return $this-&gt;hook(&quot;/msg/delete/{$message_id}&quot;,&quot;post&quot;, $request);
    }



Thanks again for the great work!</description>
		<content:encoded><![CDATA[<p>Hi Aaron, thanks for the response.  it turns out that the delete_message function needs to be altered slightly.  There needs to be a body to the post or it will return a redirect.</p>
<p>I&#8217;ve posted the code changed here: <a href="http://forum.37signals.com/basecamp/forums/8/topics/6420?page=1#posts-22139" rel="nofollow">http://forum.37signals.com/basecamp/forums/8/topics/6420?page=1#posts-22139</a></p>
<p>This</p>
<p>// Delete the message with the given id.<br />
    function delete_message($message_id) {<br />
        return $this-&gt;hook(&#8220;/msg/delete/{$message_id}&#8221;,&#8221;post&#8221;);<br />
    }</p>
<p>needs to be changed to something like this </p>
<p>// Delete the message with the given id.<br />
    function delete_message($message_id) {<br />
        $request['post'] = &#8220;delete&#8221;;<br />
        return $this-&gt;hook(&#8220;/msg/delete/{$message_id}&#8221;,&#8221;post&#8221;, $request);<br />
    }</p>
<p>Thanks again for the great work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AQ</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-30754</link>
		<dc:creator>AQ</dc:creator>
		<pubDate>Mon, 16 Jun 2008 16:17:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-30754</guid>
		<description>@Dan: Maybe its a permissions thing with messages?</description>
		<content:encoded><![CDATA[<p>@Dan: Maybe its a permissions thing with messages?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-30752</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Mon, 16 Jun 2008 16:05:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-30752</guid>
		<description>Hi There,

First off thanks for the great wrapper!

I can successfully log in and create messages using the wrapper, although trying to delete a message using the delete_message function returns a 

&quot;You are being redirected&quot;  response in html, not even in xml.  do you have any idea why this might be happening?

Thanks in advance
Dan</description>
		<content:encoded><![CDATA[<p>Hi There,</p>
<p>First off thanks for the great wrapper!</p>
<p>I can successfully log in and create messages using the wrapper, although trying to delete a message using the delete_message function returns a </p>
<p>&#8220;You are being redirected&#8221;  response in html, not even in xml.  do you have any idea why this might be happening?</p>
<p>Thanks in advance<br />
Dan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: QuirkeyBlog &#187; Blog Archive &#187; More fun with the Basecamp PHP Wrapper</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-375</link>
		<dc:creator>QuirkeyBlog &#187; Blog Archive &#187; More fun with the Basecamp PHP Wrapper</dc:creator>
		<pubDate>Wed, 02 Aug 2006 04:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-375</guid>
		<description>[...] More fun with the Basecamp PHP Wrapper  First The Wrapper, Introduction, Part 1  So jumping right in . . .  I&#8217;ve been working on a little application using the Basecamp Wrapper, and basically just fooling around with the UI now. Just because I&#8217;m dicking around, doesn&#8217;t mean you should have to suffer. So here are some nuggets.  The idea for the app was that I wanted a big simple todo list that combined all the todos I had from all the different projects in a meaningful and useful order. So first and foremost its collecting all the todos in a single array and then making use of them.  In my Customcamp class: [...]</description>
		<content:encoded><![CDATA[<p>[...] More fun with the Basecamp PHP Wrapper  First The Wrapper, Introduction, Part 1  So jumping right in . . .  I&#8217;ve been working on a little application using the Basecamp Wrapper, and basically just fooling around with the UI now. Just because I&#8217;m dicking around, doesn&#8217;t mean you should have to suffer. So here are some nuggets.  The idea for the app was that I wanted a big simple todo list that combined all the todos I had from all the different projects in a meaningful and useful order. So first and foremost its collecting all the todos in a single array and then making use of them.  In my Customcamp class: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AQ</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-152</link>
		<dc:creator>AQ</dc:creator>
		<pubDate>Sun, 02 Jul 2006 20:08:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-152</guid>
		<description>Hey Todd,
Thanks for all the work you put in to this. I&#039;ll deffinately have to try out the attachments sending. In terms of using cURL v. the PEAR classes:
cURL is great becasue it is easy to port to different languages and its built into most PHP distributions. I ended up NOT using it for the primary reason that its not in ALL distributions and if you&#039;re on a shared server, like me, its impossible to get something like that installed if its not there. Since the PEAR classes are just PHP, if neccesary you could just download the required classes and put them in the right directory. To me, thats ultimately more portable.</description>
		<content:encoded><![CDATA[<p>Hey Todd,<br />
Thanks for all the work you put in to this. I&#8217;ll deffinately have to try out the attachments sending. In terms of using cURL v. the PEAR classes:<br />
cURL is great becasue it is easy to port to different languages and its built into most PHP distributions. I ended up NOT using it for the primary reason that its not in ALL distributions and if you&#8217;re on a shared server, like me, its impossible to get something like that installed if its not there. Since the PEAR classes are just PHP, if neccesary you could just download the required classes and put them in the right directory. To me, thats ultimately more portable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-130</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Thu, 29 Jun 2006 00:18:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-130</guid>
		<description>Sorry, last time I&#039;ll bother you.  Here&#039;s a function that seems to work:

/*===================/
	 * 	Post a file  
	/*===================*/
	// thanks to http://www.basecamphq.com/forum/viewtopic.php?pid=8755 and http://playground.jwscripts.com/postdata.phps
	
	function post_file($file_path) {
		// read the file in
		$fp=fopen($file_path,&quot;r&quot;);
		$binary=fread($fp,filesize($file_path));
		$filebasename=basename($file_path);
		fclose($fp);
		
		$body = array();
		$headers = array();
		
		// Parse binary data
		// $boundary = uniqid();
		// $body[] = &quot;--$boundary\r\n&quot;;
		// $body[] = &quot;Content-Disposition: form-data; filename=\&quot;$filebasename\&quot;\r\n&quot;;
		// $body[] = &quot;Content-Type: image/jpeg\r\n\r\n&quot;;
		$body[] = &quot;$binary&quot;;
		// $body[] = &quot;--$boundary--\r\n&quot;;
		
		// Construct the headers
		$the_host=str_replace(&quot;https://&quot;,&quot;&quot;,str_replace(&quot;http://&quot;,&quot;&quot;,$this-&gt;base));
		
		// set the port, check for ssl
		$the_port=80;
		if(strstr($this-&gt;base,&quot;https&quot;)) {
			$the_port=443;
			$the_host=&quot;ssl://&quot;.$the_host;
		}
		
		$headers[] = &quot;POST /upload HTTP/1.0\r\n&quot;;
		$headers[] = &quot;Host: $the_host\r\n&quot;;
		$headers[] = &quot;Authorization: Basic &quot;.base64_encode(&quot;{$this-&gt;user}:{$this-&gt;pass}&quot;).&quot;\r\n&quot;;
		$headers[] = &quot;Accept: application/xml\r\n&quot;;
		$headers[] = &quot;Content-Type: application/octet-stream\r\n&quot;;
		$headers[] = &#039;Content-Length: &#039; . strlen(implode(&#039;&#039;, $body)) . &quot;\r\n\r\n&quot;;
		
		// open the connection
		if ($fp = fsockopen($the_host, $the_port, $errno, $errmsg, 30)) {
			foreach ($headers as $line) {
				fwrite($fp, $line);
			}
			foreach ($body as $line) {
				fwrite($fp, $line);
			}
			
			$fp_response=&quot;&quot;;
			while (!feof($fp)) {
			   $fp_response.=fgets($fp, 128);
		    }
		    fclose($fp);
			
			// remove headers
			$fp_noheaders=explode(&quot;\r\n\r\n&quot;,$fp_response);
			// echo $fp_noheaders[1];
			
			$response=$this-&gt;unserialize($fp_noheaders[1]);
		
			return $response;
		} else {
			return false;
		}
	}</description>
		<content:encoded><![CDATA[<p>Sorry, last time I&#8217;ll bother you.  Here&#8217;s a function that seems to work:</p>
<p>/*===================/<br />
	 * 	Post a file<br />
	/*===================*/<br />
	// thanks to <a href="http://www.basecamphq.com/forum/viewtopic.php?pid=8755" rel="nofollow">http://www.basecamphq.com/forum/viewtopic.php?pid=8755</a> and <a href="http://playground.jwscripts.com/postdata.phps" rel="nofollow">http://playground.jwscripts.com/postdata.phps</a></p>
<p>	function post_file($file_path) {<br />
		// read the file in<br />
		$fp=fopen($file_path,&#8221;r&#8221;);<br />
		$binary=fread($fp,filesize($file_path));<br />
		$filebasename=basename($file_path);<br />
		fclose($fp);</p>
<p>		$body = array();<br />
		$headers = array();</p>
<p>		// Parse binary data<br />
		// $boundary = uniqid();<br />
		// $body[] = &#8220;&#8211;$boundary\r\n&#8221;;<br />
		// $body[] = &#8220;Content-Disposition: form-data; filename=\&#8221;$filebasename\&#8221;\r\n&#8221;;<br />
		// $body[] = &#8220;Content-Type: image/jpeg\r\n\r\n&#8221;;<br />
		$body[] = &#8220;$binary&#8221;;<br />
		// $body[] = &#8220;&#8211;$boundary&#8211;\r\n&#8221;;</p>
<p>		// Construct the headers<br />
		$the_host=str_replace(&#8220;https://&#8221;,&#8221;",str_replace(&#8220;http://&#8221;,&#8221;",$this-&gt;base));</p>
<p>		// set the port, check for ssl<br />
		$the_port=80;<br />
		if(strstr($this-&gt;base,&#8221;https&#8221;)) {<br />
			$the_port=443;<br />
			$the_host=&#8221;ssl://&#8221;.$the_host;<br />
		}</p>
<p>		$headers[] = &#8220;POST /upload HTTP/1.0\r\n&#8221;;<br />
		$headers[] = &#8220;Host: $the_host\r\n&#8221;;<br />
		$headers[] = &#8220;Authorization: Basic &#8220;.base64_encode(&#8220;{$this-&gt;user}:{$this-&gt;pass}&#8221;).&#8221;\r\n&#8221;;<br />
		$headers[] = &#8220;Accept: application/xml\r\n&#8221;;<br />
		$headers[] = &#8220;Content-Type: application/octet-stream\r\n&#8221;;<br />
		$headers[] = &#8216;Content-Length: &#8216; . strlen(implode(&#8221;, $body)) . &#8220;\r\n\r\n&#8221;;</p>
<p>		// open the connection<br />
		if ($fp = fsockopen($the_host, $the_port, $errno, $errmsg, 30)) {<br />
			foreach ($headers as $line) {<br />
				fwrite($fp, $line);<br />
			}<br />
			foreach ($body as $line) {<br />
				fwrite($fp, $line);<br />
			}</p>
<p>			$fp_response=&#8221;";<br />
			while (!feof($fp)) {<br />
			   $fp_response.=fgets($fp, 128);<br />
		    }<br />
		    fclose($fp);</p>
<p>			// remove headers<br />
			$fp_noheaders=explode(&#8220;\r\n\r\n&#8221;,$fp_response);<br />
			// echo $fp_noheaders[1];</p>
<p>			$response=$this-&gt;unserialize($fp_noheaders[1]);</p>
<p>			return $response;<br />
		} else {<br />
			return false;<br />
		}<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-124</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Wed, 28 Jun 2006 01:53:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-124</guid>
		<description>Sorry, I guess my upload function does not work.  For some reason, the basecamp site does not strip off the formdata stuff.  Let me know if there is a better way to do this.

Thanks.</description>
		<content:encoded><![CDATA[<p>Sorry, I guess my upload function does not work.  For some reason, the basecamp site does not strip off the formdata stuff.  Let me know if there is a better way to do this.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-123</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Tue, 27 Jun 2006 22:13:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-123</guid>
		<description>Added the attachments to the creat_message function:

function create_message($project_id, $message, $notify = false, $attachments = false) {
		$request[&#039;post&#039;] = $message;
		if ($notify) {$request[&#039;notify&#039;] = $notify;}
		if ($attachments) {$request[&#039;attachments&#039;] = $attachments ;}
		return $this-&gt;hook(&quot;/projects/{$project_id}/msg/create&quot;,&quot;post&quot;,$request);
	}</description>
		<content:encoded><![CDATA[<p>Added the attachments to the creat_message function:</p>
<p>function create_message($project_id, $message, $notify = false, $attachments = false) {<br />
		$request['post'] = $message;<br />
		if ($notify) {$request['notify'] = $notify;}<br />
		if ($attachments) {$request['attachments'] = $attachments ;}<br />
		return $this-&gt;hook(&#8220;/projects/{$project_id}/msg/create&#8221;,&#8221;post&#8221;,$request);<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-122</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Tue, 27 Jun 2006 21:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-122</guid>
		<description>I just wrote a CURL based function and added it to your class.  Feel free to add it to yours. Now I just need to work on the attachements thing...

/*===================/
	 * 	Post a file  
	/*===================*/
	// thanks to http://www.basecamphq.com/forum/viewtopic.php?pid=8755
	
	function post_file($file_path) {
		$postData = array();
		
		//simulates 
		$postData[ &#039;file_name&#039; ] = &quot;@$file_path&quot;;
		$postData[ &#039;submit&#039; ] = &quot;UPLOAD&quot;;
		
		$ch = curl_init();
		
		$request =  $this-&gt;base.&#039;/upload&#039;;

		error_reporting(E_ALL);
	
		curl_setopt($ch, CURLOPT_URL, $request); // set url to post to
		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch, CURLOPT_POST, 1 );
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(&#039;Accept: application/xml&#039;, &#039;Content-Type: application/xml&#039;));
		
		//seems no need to tell it enctype=&#039;multipart/data&#039; it already knows
		curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
		
		// provide credentials if they&#039;re established at the beginning of the script
		if(!empty($this-&gt;user) &amp;&amp; !empty($this-&gt;pass)) {
			curl_setopt($ch,CURLOPT_USERPWD,$this-&gt;user . &quot;:&quot; . $this-&gt;pass);
		}
		
		// tell cURL to graciously accept an SSL certificate if presented
    	if(ereg(&quot;^(https)&quot;,$request)) {
			curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
		}
		
		$response_xml = curl_exec( $ch );
		
		$response=$this-&gt;unserialize($response_xml);
		
		return $response;
	}</description>
		<content:encoded><![CDATA[<p>I just wrote a CURL based function and added it to your class.  Feel free to add it to yours. Now I just need to work on the attachements thing&#8230;</p>
<p>/*===================/<br />
	 * 	Post a file<br />
	/*===================*/<br />
	// thanks to <a href="http://www.basecamphq.com/forum/viewtopic.php?pid=8755" rel="nofollow">http://www.basecamphq.com/forum/viewtopic.php?pid=8755</a></p>
<p>	function post_file($file_path) {<br />
		$postData = array();</p>
<p>		//simulates<br />
		$postData[ 'file_name' ] = &#8220;@$file_path&#8221;;<br />
		$postData[ 'submit' ] = &#8220;UPLOAD&#8221;;</p>
<p>		$ch = curl_init();</p>
<p>		$request =  $this-&gt;base.&#8217;/upload&#8217;;</p>
<p>		error_reporting(E_ALL);</p>
<p>		curl_setopt($ch, CURLOPT_URL, $request); // set url to post to<br />
		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);<br />
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);<br />
		curl_setopt($ch, CURLOPT_POST, 1 );<br />
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(&#8216;Accept: application/xml&#8217;, &#8216;Content-Type: application/xml&#8217;));</p>
<p>		//seems no need to tell it enctype=&#8217;multipart/data&#8217; it already knows<br />
		curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );</p>
<p>		// provide credentials if they&#8217;re established at the beginning of the script<br />
		if(!empty($this-&gt;user) &amp;&amp; !empty($this-&gt;pass)) {<br />
			curl_setopt($ch,CURLOPT_USERPWD,$this-&gt;user . &#8220;:&#8221; . $this-&gt;pass);<br />
		}</p>
<p>		// tell cURL to graciously accept an SSL certificate if presented<br />
    	if(ereg(&#8220;^(https)&#8221;,$request)) {<br />
			curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);<br />
		}</p>
<p>		$response_xml = curl_exec( $ch );</p>
<p>		$response=$this-&gt;unserialize($response_xml);</p>
<p>		return $response;<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/comment-page-1/#comment-121</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Tue, 27 Jun 2006 21:01:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.quirkey.com/blog/2006/06/20/using-the-basecamp-php-wrapper/#comment-121</guid>
		<description>Any chance you can publish a quick example for uploading files to basecamp using your class, then attaching it to a message?

Thanks.</description>
		<content:encoded><![CDATA[<p>Any chance you can publish a quick example for uploading files to basecamp using your class, then attaching it to a message?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

