<?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>vividlamp.net</title>
	<atom:link href="http://vividlamp.net/feed" rel="self" type="application/rss+xml" />
	<link>http://vividlamp.net</link>
	<description>Growing Ideas</description>
	<lastBuildDate>Tue, 05 Jan 2010 10:18:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Paypal Affiliate Script</title>
		<link>http://vividlamp.net/uncategorized/paypal-affiliate-script</link>
		<comments>http://vividlamp.net/uncategorized/paypal-affiliate-script#comments</comments>
		<pubDate>Tue, 05 Jan 2010 10:18:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vividlamp.net/?p=93</guid>
		<description><![CDATA[Create a customised affiliate program on your own website
Offer your own affiliate program with PhpAffiliate designed especially for merchants who favor Paypal. Works with all Paypal buttons including Paypal IPN scripts. [Find out more]
]]></description>
			<content:encoded><![CDATA[<p></p><p><strong>Create a customised affiliate program on your own website</strong></p>
<p>Offer your own affiliate program with PhpAffiliate designed especially for merchants who favor Paypal. Works with all Paypal buttons including Paypal IPN scripts. <a href="http://www.idevspot.com/PhpAffiliate.php?xyz=396">[Find out more]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vividlamp.net/uncategorized/paypal-affiliate-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter Backgrounds</title>
		<link>http://vividlamp.net/scripts/twitter-backgrounds</link>
		<comments>http://vividlamp.net/scripts/twitter-backgrounds#comments</comments>
		<pubDate>Tue, 05 Jan 2010 06:52:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://vividlamp.net/?p=87</guid>
		<description><![CDATA[Create your own Twitter Background website with these 200+ backgrounds pack.
It is now really easy to start your own Twitter Background website. With over 200+ unique designs you can quickly get up and running with this great pack. [Find out more]
]]></description>
			<content:encoded><![CDATA[<p></p><p><strong>Create your own Twitter Background website with these 200+ backgrounds pack.</strong></p>
<p>It is now really easy to start your own Twitter Background website. With over 200+ unique designs you can quickly get up and running with this great pack. <a href="http://www.twitterscripts.net/twitter-background-packs.php?xyz=71">[Find out more]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vividlamp.net/scripts/twitter-backgrounds/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build a simple twitter threaded conversation script</title>
		<link>http://vividlamp.net/tutorial/build-a-simple-twitter-threaded-conversation-script</link>
		<comments>http://vividlamp.net/tutorial/build-a-simple-twitter-threaded-conversation-script#comments</comments>
		<pubDate>Fri, 20 Nov 2009 10:27:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[threaded conversation]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://vividlamp.net/?p=21</guid>
		<description><![CDATA[Sometimes it can be hard to keep track of all your conversations on twitter. To track whats been said to who you need to look through your mentions/replies and also look through your own status timeline. Here is a basic introduction on how to set up a simple threaded conversation script in php so you [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Sometimes it can be hard to keep track of all your conversations on twitter. To track whats been said to who you need to look through your mentions/replies and also look through your own status timeline. Here is a basic introduction on how to set up a simple threaded conversation script in php so you can see a conversation on one page.</p>
<div id="note"><strong>What You Need:</strong></p>
<ul>
<li>Server or PC running Php 5.2+</li>
<li>You will also need to get the twitter library from github &#8211; <a href="http://github.com/jdp/twitterlibphp">twitter.lib.php</a>. It was created by Justin Poliey and uses a simple interface to easily connect to all of twitters api methods. Take a look through the documentation provided to see the various methods that are supported.</li>
</ul>
</div>
<p><span id="more-21"></span> First, lets include the twitter.lib.php file into our script:</p>
<pre>	include("includes/twitter.lib.php");</pre>
<p>Next, we need to create a new instance of the Twitter class, passing in our Twitter username and password:</p>
<pre>	$username = "twitter_username";
	$password = "twitter_password";
	$twitter = new Twitter($username, $password);</pre>
<p>Now that we have created a twitter object we can now use some methods to get data out of the twitter api. To build our threaded conversation script we will need to get any occurrences where someone has mentioned us.</p>
<pre>	// This array is passed into getMentions, for this example we will pass a blank array
	// Options can include: page, count, since_id, max_id
	$arrOptions = Array(); 

	// Get statuses where you are mentioned
	$mentions = $twitter-&gt;getMentions($arrOptions);

	// Convert the xml document into an array
	$mentions = simplexml_load_string($mentions);</pre>
<p>The above code will return the 20 most recent mentions (status containing @username) for the authenticating user. To see all the options that can be passed into the statuses/mentions api call view the <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-mentions">Twitter Status/Mentions API page</a>.</p>
<p>In the following chunk of code we will loop through the <code>$mentions</code> array, check if the users screen name matches the friend that we wish to see a mention history of and if it does pop it into an array called <code>$statuses</code>. You will notice that the status array is indexed by status id (<code>$item-&gt;id</code>), this is so we can later sort the index in sequence of when the status occurred.</p>
<pre>$user_to = "friends_username";

foreach ($mentions as $item) {
	if ($item-&gt;user-&gt;screen_name == $user_to) {
		//Use status id as index so we can get the sequence correct
		$index = (string) $item-&gt;id;
		$statuses[$index]["screen_name"] = (string) $item-&gt;user-&gt;screen_name;
		$statuses[$index]["url"] = (string) $item-&gt;user-&gt;url;
		$statuses[$index]["profile_image_url"] = (string) $item-&gt;user-&gt;profile_image_url;
		$statuses[$index]["text"] = (string) $item-&gt;text;
	}
}</pre>
<div id="note">Note: Each call to the <code>$item</code> array is cast as a string &#8211; <code>(string)</code>. This is because each item is an xml object and if we don&#8217;t store it as a string it can cause us grief later.</div>
<p>Now we need to get the data from our own timeline and find all the responses we made.</p>
<pre>	// Passed into getUserTimeline
	$arrOptions = Array();

	// Get your status timeline
	$timeline = $twitter-&gt;getUserTimeline($arrOptions);

	// Convert the xml document into an array
	$timeline = simplexml_load_string($timeline);</pre>
<p>Again we need to loop through each item in the array and filter any responses to the user we are interested in. You will notice I use <code>in_reply_to_screen_name</code>, this is a quick way to see who the selected status was directed to.</p>
<pre>foreach ($timeline as $item) {
 	if ($item-&gt;in_reply_to_screen_name == $user_to) {
		$index = (string) $item-&gt;id;
		$statuses[$index]["screen_name"] = (string) $item-&gt;user-&gt;screen_name;
		$statuses[$index]["url"] = (string) $item-&gt;user-&gt;url;
		$statuses[$index]["profile_image_url"] = (string) $item-&gt;user-&gt;profile_image_url;
		$statuses[$index]["text"] = (string) $item-&gt;text;
	}
}</pre>
<p>So now lets sort the $statuses array by key using $ksort:</p>
<pre>	//Sort array by key
	ksort($statuses);</pre>
<p>This php sort function is perfect for this application as it will sort by key (low to high) and maintains key association. For a list of the various php array sorts, take a look at <a href="http://www.php.net/manual/en/array.sorting.php">Sorting Arrays</a>.</p>
<p>Then its just a case of looping though our <code>$statuses</code> array and display the information in a nice format:</p>
<pre>foreach ($statuses as $item) {
  echo "&lt;div style='padding:10px;width:500px;border-bottom:1px dotted #000;overflow:hidden;'&gt;";
  echo "&lt;img src='".$item["profile_image_url"]."' height='48px' width='48px' align='left'&gt; ".$item["screen_name"].": ".$item["text"];
  echo "&lt;/div&gt;";
}</pre>
<p>And thats it. A very simple threaded conversation script that could easily be developed further into a full application.</p>
<div id="note">Most of the Twitter Library methods have an optional format parameter, for this tutorial we have used the default xml for simplicity. Other options include: json, rss and atom depending on the method you are using.</div>
]]></content:encoded>
			<wfw:commentRss>http://vividlamp.net/tutorial/build-a-simple-twitter-threaded-conversation-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
