<?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>Hayden Kibble &#187; email</title>
	<atom:link href="http://www.haydenkibble.com/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.haydenkibble.com</link>
	<description>PHP-SEO-IM-DESIGN</description>
	<lastBuildDate>Fri, 17 Dec 2010 23:06:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Make Your Phone &#8216;Kerching&#8217; When You Make A Sale</title>
		<link>http://www.haydenkibble.com/2009/07/make-your-phone-kerching-when-you-make-a-sale/</link>
		<comments>http://www.haydenkibble.com/2009/07/make-your-phone-kerching-when-you-make-a-sale/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 19:23:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Internet Marketing]]></category>
		<category><![CDATA[PHP/MySQL/AJAX]]></category>
		<category><![CDATA[affiliate]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[kerching]]></category>
		<category><![CDATA[notification]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sale]]></category>

		<guid isPermaLink="false">http://www.haydenkibble.com/?p=15</guid>
		<description><![CDATA[Being the egotistical git I am, I wanted my phone to make a &#8216;kerching&#8217; sound each time I made an affiliate sale. Nothing beats dozing off on a lazy Sunday evening and hearing your cash register ring out. Here&#8217;s how I made it happen&#8230;
First, you need to receive an email each time you make a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.haydenkibble.com/wp-content/uploads/cash-register-150x150.jpg" alt="cash-register" title="cash-register" width="150" height="150" class="alignright size-thumbnail wp-image-33" />Being the egotistical git I am, I wanted my phone to make a &#8216;kerching&#8217; sound each time I made an affiliate sale. Nothing beats dozing off on a lazy Sunday evening and hearing your cash register ring out. Here&#8217;s how I made it happen&#8230;</p>
<p>First, you need to receive an email each time you make a sale. If your affiliate network will do this, then the first bit is already done. If not, copy the script below into a php file called something like  &#8216;xml-to-email.php&#8217; and upload it to your web server. Full instructions are in comments at the top of the file. You will most likely have to change the regex variable to work with your affiliate network&#8217;s own feed format.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #########################################################
&nbsp;
Email When You Make a Sale
Developed by Hayden Kibble July 2009
Hayden@HaydenKibble.com
www.HaydenKibble.com
&nbsp;
Install instructions:
1. Put your affiliate network login and your email details into the variables below
2. You will probably have to edit '$regex_saletime' to match the sale time/date for your paticular aff networks xml feed
2. Upload this file to your web server.
3. Create a file called 'sales.txt' in the same directory as this script and make sure it has read/write permissions
4. Visit the page and it should show a blank page. An email will probably be sent as it picks up all your recent sales
5. Set a cron job up on your web server to run this script every 10 mins or so
6. If you have problems with any of the above, Google is your friend!
&nbsp;
######################################################### */</span>
&nbsp;
<span style="color: #000088;">$base_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;https://www.affilliate-network.com/myfeed.xml&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$feed_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;USERNAME-HERE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$feed_pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;PASSWORD-HERE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$regex_saletime</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/&lt;date&gt;(.*)&lt;\/date&gt;/U&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$email_from</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;from@address.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$email_to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;to@address.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$email_subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;You Made a Sale!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ##### Do Not Edit Below This Line! #####</span>
&nbsp;
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$base_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set your login and password for authentication</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #000088;">$feed_user</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">':'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$feed_pass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HTTPAUTH<span style="color: #339933;">,</span> CURLAUTH_ANY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_SSL_VERIFYPEER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// get the data and close the session</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error Getting Feed.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$dates</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$regex_saletime</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #000088;">$dates</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Read previous sales times from database</span>
<span style="color: #000088;">$fileData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myFile</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;sales.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fh</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fileData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #339933;">,</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Split the file into lines</span>
<span style="color: #000088;">$fileLines</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$fileData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$newsale</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$fh</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;can't open file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// See if this sale has already been logged. If not, log it and set 'new sale' variable</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dates</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$date</span><span style="color: #339933;">,</span><span style="color: #000088;">$fileLines</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$newsale</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sale_time</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$newsale</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email_to</span><span style="color: #339933;">,</span><span style="color: #000088;">$email_subject</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;You have made a sale.<span style="color: #000099; font-weight: bold;">\n</span>Sale Time: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sale_time</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;From: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$email_from</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>To test, empty the  sales.txt file you created and run (access) the script. It will see your recent sales have not been logged and fire off the email. Make sure the email does not go to your junk folder.</p>
<p>If you want your computer to play a &#8216;kerching&#8217; upon making a sale, you can simply set up a rule in Microsoft Outlook to play the sound upon receiving an email with &#8216;Payment Received&#8217; in the subject. You get the idea.</p>
<p>For those of you who want the full-on portable cash register, continue on to create a gmail account with a difficult to guess name <em>just for these emails</em>. If you share this address <em>anywhere</em> it will get spammed. We do not want this as you will start hearing an awful lot of incorrect kerching&#8217;s!</p>
<p>You now need to set your phone up to use your gmail account. Make it check for new emails every 10 mins or so (depending on how often you set your cron job to run the script) and set <a href="http://www.haydenkibble.com/downloads/kerching.wav">this kerching wav</a> as your notification sound.</p>
<p>You are now set! When the php script runs intermittently on the cron job, it parses the feed for new sales. When it finds a new sale it sends an email to your phone, which plays a &#8216;kerching&#8217; sound on receipt!</p>
<p><a href="http://www.haydenkibble.com/?ibsa=share&amp;id=15" id="share-link-">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.haydenkibble.com/2009/07/make-your-phone-kerching-when-you-make-a-sale/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://www.haydenkibble.com/downloads/kerching.wav" length="12384" type="audio/x-wav" />
<enclosure url="http://www.haydenkibble.com/downloads/kerching.wav" length="12384" type="audio/x-wav" />
		</item>
	</channel>
</rss>

