<?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>Mike Luby &#187; PHP</title>
	<atom:link href="http://www.mikeluby.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikeluby.com</link>
	<description>acts smart.</description>
	<lastBuildDate>Wed, 23 Dec 2009 15:45:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple Gnip example</title>
		<link>http://www.mikeluby.com/2009/06/07/simple-gnip-example/</link>
		<comments>http://www.mikeluby.com/2009/06/07/simple-gnip-example/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 06:37:48 +0000</pubDate>
		<dc:creator>Mike Luby</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mikeluby.com/?p=193</guid>
		<description><![CDATA[If you&#8217;re unfamiliar with Gnip (http://gnip.com/) pronounced &#8220;Guh-nip&#8221; it&#8217;s a content distribution solution for multiple publishers such as twitter, digg, flickr, tumblr, and many more. Rather than polling the service, Gnip allows you to set up a &#8220;push&#8221; type system where you let a callback URL and when there are new activities or notifications gnip [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re unfamiliar with Gnip (<a title="Gnip" href="http://gnip.com">http://gnip.com/</a>) pronounced &#8220;Guh-nip&#8221; it&#8217;s a content distribution solution for multiple publishers such as twitter, digg, flickr, tumblr, and many more. Rather than polling the service, Gnip allows you to set up a &#8220;push&#8221; type system where you let a callback URL and when there are new activities or notifications gnip will notify you through the URL provided. What I plan to show you here is a quick bit of code that allows you to quickly retrieve activities from filters using the <a title="Gnip PHP Convience Library" href="http://github.com/gnip/gnip-php/tree/master">Gnip PHP Convenience Library</a>. I&#8217;m not going to go into a huge amount of depth and I also assume that you know basic programming/PHP paradigms</p>
<p>OK lets get started, what you&#8217;ll want to do first is to create a simple filter, I&#8217;ll be using the twitter-search publisher for this. So lets say you wanted to get all of the tweets that have the keywords &#8220;@mikeluby&#8221;, &#8220;mike luby&#8221;, and &#8220;mikeluby.com&#8221;. You would start by creating the filter, lets name it &#8220;aboutMikeLuby&#8221; next you&#8217;ll want to put the URL to your callback (lets use http://example.com/gnip_input.php). Finally at the bottom you&#8217;ll enter the keywords into the keyword input. This input is comma separated and will simulate an OR conditionals to the twitter search api. Now there is away to create these filters via code, I&#8217;ll get into this at a later date. When the activities are returned they are grouped into buckets, there is a new bucket every minute.</p>
<p>At this point you&#8217;ll want to make sure you have the Gnip PHP Convenience Library downloaded. (Get it <a title="Gnip PHP Convience Library" href="http://github.com/gnip/gnip-php/tree/master">here</a>) In gnip_input.php (the callback when gnip &#8220;pushes&#8221; data to your service) you&#8217;ll have the following:</p>
<pre class="brush: php;">

//This file is called every time Gnip has activities to publish to the current bucket.

include_once( &quot;Gnip.php&quot; );

$time = time(); //Get current time

$gnip = new Services_Gnip( $gnip_username, $gnip_password ); //Create gnip Object

$filter = $gnip-&gt;getFilter( &quot;twitter-search&quot;, &quot;aboutMikeLuby&quot; ); //Create filter object

$results = $gnip-&gt;getFilterActivities( &quot;twitter-search&quot;, $filter, $time ); //This returns a Services_Gnip Object of the activites in the specified bucket.

print_r( $results );
</pre>
<p>There you go, it&#8217;s pretty straight forward. Don&#8217;t forget to check out <a title="Gnip's Documentation" href="http://docs.google.com/Doc?id=dpw6zj9_0fdcnttgd">Gnip&#8217;s documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeluby.com/2009/06/07/simple-gnip-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code snippet: tinyurl link creation api</title>
		<link>http://www.mikeluby.com/2008/09/29/code-snippet-tinyurl-link-creation-api/</link>
		<comments>http://www.mikeluby.com/2008/09/29/code-snippet-tinyurl-link-creation-api/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 16:34:14 +0000</pubDate>
		<dc:creator>Mike Luby</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://lubymike.wordpress.com/?p=73</guid>
		<description><![CDATA[Here is a quick code snippet to use the tinyurl link creation api.
&#60; ?php
//tinyURL function, needs url to be passed to tinyrul
function tinyURL( $url ) {
	//Initializes a new session and return a cURL handle
	$curl = curl_init( );
	//Sets an option on the given cURL session handle.
	//request url
	curl_setopt( $curl, CURLOPT_URL, &#34;http://tinyurl.com/api-create.php?url=&#34; . urlencode( $url ) );
	curl_setopt( $curl, [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick code snippet to use the tinyurl link creation api.</p>
<pre class="brush: php;">&lt; ?php
//tinyURL function, needs url to be passed to tinyrul
function tinyURL( $url ) {
	//Initializes a new session and return a cURL handle
	$curl = curl_init( );
	//Sets an option on the given cURL session handle.
	//request url
	curl_setopt( $curl, CURLOPT_URL, &quot;http://tinyurl.com/api-create.php?url=&quot; . urlencode( $url ) );
	curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); //return transfer
	curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 10 ); // connection timeout
	//Execute the given cURL session.
	$tiny = curl_exec( $curl );
	//Closes a cURL session and frees all resources. The cURL handle, $curl , is also deleted.
	curl_close( $curl );
	//return result from curl
	return( $tiny );
}

echo tinyURL( &quot;http://strategicv.com/&quot; ); //echos: http://tinyurl.com/3r4j8c
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeluby.com/2008/09/29/code-snippet-tinyurl-link-creation-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
