<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OSTalks &#187; curl</title>
	<atom:link href="http://www.ostalks.com/tag/curl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ostalks.com</link>
	<description>Open Source, Operating Systems, Offtopic Stuff!</description>
	<lastBuildDate>Fri, 28 May 2010 01:29:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Heywatch and php</title>
		<link>http://www.ostalks.com/2009/09/07/heywatch-and-php/</link>
		<comments>http://www.ostalks.com/2009/09/07/heywatch-and-php/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 11:20:23 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[heywatch]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://ostalks.wordpress.com/?p=61</guid>
		<description><![CDATA[Heywatch is a cool video encoding web service that is being used by different clients like Sony, Fotolia, Kickapps, MTv, among others for their video conversion needs.]]></description>
			<content:encoded><![CDATA[<p>Heywatch is a cool video encoding web service that is being used by different clients like Sony, Fotolia, Kickapps, MTv, among others for their video conversion needs.</p>
<p>One nice thing about this service is that it has a REST based API that is simple to implement in php.  However, the documentation that comes with heywatch shows only how to access the API using PEAR &#8211; this becomes a disadvantage if your shared hosted webhost doesn&#8217;t have PEAR installed.  I also personally think that using PEAR just to call this api is basically overkill.</p>
<p>Why not use curl instead?  I basically changed the PEAR functions in the API documentation to that of php curl functions (which are basically native and available in practically all shared php webhosting)</p>
<p><code><br />
&lt;?<br />
$video_url = "http://osaddict.com/files/elephantsdream-480-h264-st-aac.mov";<br />
$format_id = "1086"; // 1086 for flash h264, 31 for flash flv<br />
$ftp = "ftp://username:password@ftphost.com";<br />
$ping_after_encode = "http://host/heywatch/success.php?myvideoid=5&amp;myuserid=1";<br />
$ping_if_error = "http://host/heywatch/error.php";<br />
$ch = curl_init();<br />
$your_username = "";<br />
$your_password = "";<br />
$video_url,"format_id"=&gt;$format_id,"automatic_encode"=&gt;"true","ftp_directive"=&gt;$ftp,"title"=&gt;"My Video Title","keep_video_size"=&gt;"true");<br />
curl_setopt($ch, CURLOPT_USERPWD, $your_username.':'.$your_password);<br />
curl_setopt($ch, CURLOPT_POSTFIELDS,$arr);</code></p>
<p>$data = curl_exec($ch);</p>
<p>if (curl_errno($ch)) {<br />
print curl_error($ch);<br />
exit;<br />
} else {<br />
curl_close($ch);<br />
}</p>
<p>header(&#8220;Content-Type: text/xml;charset=UTF-8&#8243;);<br />
header(&#8220;Pragma: no-cache&#8221;);<br />
echo $data;<br />
?&gt;</p>
<p>What this code does is to download a video, convert it to h264 flash format, then upload it to a select ftp host in just one step (success.php and error.php are ping functions where the developer is notified if conversion was successful or not).</p>
<p>One thing to take note is that heywatch doesn&#8217;t like special characters in the ftp url, if you place such characters in the $ftp variable, heywatch upload fails.</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2009/09/07/heywatch-and-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://osaddict.com/files/elephantsdream-480-h264-st-aac.mov" length="103636531" type="video/quicktime" />
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.698 seconds -->
