<?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>Web Cash &#187; trackback</title>
	<atom:link href="http://www.earn-web-cash.com/tag/trackback/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.earn-web-cash.com</link>
	<description>Writing, Designing, and Making Money Online</description>
	<lastBuildDate>Sun, 04 Dec 2011 22:52:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Huzzah Akismet!  Blocking Spam Comments All Day</title>
		<link>http://www.earn-web-cash.com/2008/01/29/akismet-spam/</link>
		<comments>http://www.earn-web-cash.com/2008/01/29/akismet-spam/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 03:39:21 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Online Tools]]></category>
		<category><![CDATA[Sundry Musings]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[trackback]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/29/huzzah-akismet-blocking-spam-comments-all-day/</guid>
		<description><![CDATA[You know your site is finally getting around a bit when you start getting comments.  Spam comments.

I started a (now defunct) website last year, powered by <a href="http://www.wordpress.org">Wordpress</a>.  It never got too popular, and in the beginning I was excited every time I got a "New Comment" or "New Trackback" e-mail.  Then I realized they were mostly all spam.]]></description>
			<content:encoded><![CDATA[<p>You know your site is finally getting around a bit when you start getting comments.  Spam comments.</p>
<p>I started a (now defunct) website last year, powered by <a href="http://www.wordpress.org">WordPress</a>.  It never got too popular, and in the beginning I was excited every time I got a &#8220;New Comment&#8221; or &#8220;New Trackback&#8221; e-mail.  Then I realized they were mostly all spam.<br />
<span id="more-86"></span><br />
A few minutes ago, I checked my e-mail and had a spam comment in my inbox.  I thought, &#8220;Ahh, here comes the spam.&#8221;</p>
<p>When I logged into the dashboard, I spammed the comment and was about to move away.  Then I happened to look at the dashboard again &#8211; and I remembered that I had set up Akismet this time around.</p>
<p>I just added the widget to the left sidebar because I was so impressed.  Akismet apparently blocked 84 spam comments &#8211; and this was the first one that got through.  I&#8217;d say that&#8217;s pretty impressive.</p>
<p>If you&#8217;re running a WordPress blog, or something else that uses comments and can utilize an Akismet plug-in, <strong>do so</strong>.  There&#8217;s nothing more frustrating than wading through spam comments and trackbacks all day long.</p>
<p>Akismet is apparently pretty effective at cutting them down.  A few of them might sift through, but you can never get rid of <strong>all</strong> the spam.  So be happy if you can eliminate 84/85.</p>
<p>You can download the <a href="http://codex.wordpress.org/Akismet">Akismet plugin for WordPress</a>, but all new builds come with Akismet pre-installed.  All you have to do is fill in the Akismet API number &#8211; which you can get for free with a WordPress account.</p>
<p>Happy spam-free comment logs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/29/akismet-spam/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Write a PHP Script to Send a Trackback</title>
		<link>http://www.earn-web-cash.com/2008/01/08/how-to-write-a-php-script-to-send-a-trackback/</link>
		<comments>http://www.earn-web-cash.com/2008/01/08/how-to-write-a-php-script-to-send-a-trackback/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 01:42:13 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Redirected]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[trackback]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/08/how-to-write-a-php-script-to-send-a-trackback/</guid>
		<description><![CDATA[Don&#8217;t know what a trackback is? Check out this set of articles for a bit more information. Assuming you do know what a trackback is, how do you send one &#8211; technically speaking? And how can we write a php script to send one? A trackback is a simple ping &#8211; an HTTP Request. It [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t know what a trackback is?  Check out this <a href="http://www.earn-web-cash.com/web-design-guides/trackbacks/">set of articles</a> for a bit more information.</p>
<p>Assuming you do know what a trackback is, how do you send one &#8211; technically speaking?  And how can we write a php script to send one?</p>
<p>A trackback is a simple ping &#8211; an HTTP Request.  It is specially formatted with a limited amount of information.  The receiving server is set up to handle that information and use it to create the comment based on your trackback ping.<br />
<span id="more-29"></span></p>
<h5>The Trackback API As Per Moveable Type</h5>
<p>Since Moveable Type introduced the trackback, they were the ones responsible for writing the standards and API.  You can read through the <a href="http://www.sixapart.com/pronet/docs/trackback_spec">trackback technical specs on the SixApart website.</a></p>
<p>In order to send a trackback ping with a PHP script, there&#8217;s a few things we need to know&#8230;</p>
<ul>
<li>The ping is in the form of an HTTP Post Request.</li>
<li>The ping is sent to the trackback URI of the receiving post.</li>
<li>The request must have a content-type header defining it as <code>application/x-www-url-encoded</code></li>
<li>All of the parameters included in the content should be url encoded.</li>
<li>The standard parameters are &#8220;title,&#8221; &#8220;excerpt,&#8221; &#8220;url,&#8221; and &#8220;blog.&#8221;  Only the &#8220;url&#8221; parameter is required.</li>
<li>The server will send a short XML response &#8211; containing <code>&lt;error&gt;0&lt;/error&gt;</code> if there was no error, and <code>&lt;error&gt;1&lt;/error&gt;</code> along with a <code>&lt;message&gt;&lt;/message&gt;</code> element if there was an error.</li>
</ul>
<p>With that in mind, we can begin to write our script.  We need to do four things.</p>
<ul>
<li>Receive input from the user (the blog url, title, excerpt, etc).</li>
<li>Create the header and format the information correctly</li>
<li>Send the header and get a response</li>
<li>Read the XML to see if it was successful or not</li>
</ul>
<h5>Getting Input From the User</h5>
<p>Getting input is pretty simple.  We&#8217;ll create a form in HTML, set the action to the page containing the script, and set the method to post.</p>
<p>You&#8217;ll want a text input for the URL, title, and blog.  You could use either a text input or a small textarea box to take the excerpt.</p>
<p>Here&#8217;s some sample HTML to create the form.  You&#8217;d want to add some css to make it look pretty, but you can do that some other time.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;trackback-form&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;trackback.html&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;trackback&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;trackback-uri&quot;</span>&gt;</span>Trackback URI:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;trackback-uri&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;trackback-uri&quot;</span> </span>
<span style="color: #009900;">        <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;title&quot;</span>&gt;</span>Post Title:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;title&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;title&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span>&gt;</span>Post URL:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;excerpt&quot;</span>&gt;</span>Excerpt:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;excerpt&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;excerpt&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blog&quot;</span>&gt;</span>Blog Name:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blog&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blog&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Send Trackback Ping&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> </span>
<span style="color: #009900;">        <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>');</pre></div></div>

<p>Simple&#8230; but effective.  Set the &#8220;action&#8221; to the name of the file with the form in it.  We&#8217;ll add the php script to the top, and the form will just return the information to itself.</p>
<h5>Reading the Information from the Form and Encoding It</h5>
<p>Once you hit submit, all of the form information will get sent to the file so that the script &#8211; at the beginning of the file &#8211; can handle it.</p>
<p>All of this form information is in the $_POST array.  The &#8216;key&#8217; for each element is the &#8216;name&#8217; attribute of the form element.</p>
<p>We&#8217;ll also need to use the urlencode() function.  This takes the input and escapes any special characters (like spaces) so that the input is in the proper format.</p>
<p>Here&#8217;s a snippet to read the $_POST variables, encode them, and store the information in some new variables.  Note that you&#8217;d probably want to include some error checking (i.e. check to see if the $_POST[] element is empty, and set an error message if it is).  I&#8217;ll leave that up to you.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'excerpt'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$blog_name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'blog'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$trackback_uri</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'trackback-uri'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now that have all of our information, we need to create the HTTP header.  </p>
<p>You could format this as a special string, but php has a built in function &#8211; stream_context_create &#8211; that will take a formatted array and use it to send an HTTP header.  That&#8217;s what we&#8217;ll be using.</p>
<p>A HTTP header looks something like this&#8230;<br />
<code>
<pre>
POST http://targeturl.com
Content-Type: application/x-www-form-urlencoded; charset=utf-8

paramvar=Param+Value&#038;paramvar2=Param+Value+2
</pre>
<p></code></p>
<p>In order to use stream_context_create, we need to create an array in the following format.</p>
<ul>
<li><code>$params['http']['method']</code> is the method (POST)</li>
<li><code>$params['http']['header']</code> is the optional headers (in this case the Content-Type)</li>
<li><code>$params['http']['content']</code> is the actual content &#8211; the parameter variables and values.  This will be the string containing all of the trackback information (the post url, post title, blog name, and excerpt).</li>
</ul>
<p>So, to create the array we need, here&#8217;s a short snippet of code, picking up where we left off before&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'method'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'POST'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'header'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Content-Type: 
    application/x-www-form-urlencoded'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;title=<span style="color: #006699; font-weight: bold;">$title</span>&amp;url=<span style="color: #006699; font-weight: bold;">$url</span>&amp;
    blog_name=<span style="color: #006699; font-weight: bold;">$blog_name</span>&amp;excerpt=<span style="color: #006699; font-weight: bold;">$excerpt</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note that because we used double-quotes (&#8221; &#8220;) when declaring <code>$params['http']['content']</code>, we could simply include the variables in the string &#8211; and PHP will punch in the values for us.</p>
<h5>Send the Header!  Pings Away!</h5>
<p>Now that we&#8217;ve created the array, we&#8217;re ready to create a context and actually send the HTTP request to the target website.</p>
<p>Like I said before, we&#8217;ll use the function <code>stream_context_create</code> to do the work.  Then we&#8217;ll fopen the target, write the header, fclose the target, and save the response.</p>
<p><code>stream_context_create</code> just needs one parameter &#8211; our formatted array.</p>
<p><code>fopen</code> will take a few parameters &#8211; the target URL ($trackback_uri), the mode (&#8216;rb&#8217; for read-only, binary), a boolean option which is false for us, and the context we created with <code>stream_context_create</code>.</p>
<p>Here&#8217;s the actual code snippet.  (Note:  You can only use a context in <code>fopen()</code> in PHP 5 or greater.  You&#8217;ll need to manually make the header if you&#8217;re using PHP 4)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//  Create the context from the formatted array</span>
<span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stream_context_create</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  Open a stream to the url, save it in the pointer $fp</span>
<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trackback_uri</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rb'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  Send the header and get the results, saved in $response</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">stream_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  Always close for good measure</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>At this point, you should be able to send trackbacks just fine.</p>
<h5>Read the Result Message &#8211; Error or No?</h5>
<p>Now we need to read the results (saved in $response) and find out if we were successful.</p>
<p>You could just echo it.  The xml tags will be hidden by the browser, so the user will just see the output.  However I like to have the script read it so that I can output a customized message.</p>
<p>One way to do this would be to build an xml parser and find out directly what&#8217;s in the <code>&lt;error&gt;&lt;/error&gt;</code> element.  This is a lot of work for one error message, though.</p>
<p>Instead, we can use our knowledge of the standard format of the message to good use.</p>
<p>First, we know that a success is always returned with <code>&lt;error&gt;0&lt;/error&gt;</code>.  If we do a stripos or substr search to see if that string is included in $response, we&#8217;ll know if the test was successful or not.</p>
<p>Then, we can isolate the <code>&lt;message&gt;&lt;/message&gt;</code> element and echo that.</p>
<p>Here&#8217;s the code I used to do it.  Not sure if it&#8217;s the most efficient way to do it, but it works&#8230; so why not?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//  If this is true, there was no error</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">stripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;error&gt;0&lt;/error&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$outcome</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;All clear! Trackback 
        was sent successfully.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//  Find the beginning and end of the message element</span>
    <span style="color: #000088;">$start_resp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;message&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$end_resp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/message&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//  substr will return the actual message element, </span>
    <span style="color: #666666; font-style: italic;">//    with the tags included</span>
    <span style="color: #000088;">$outcome</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">,</span> <span style="color: #000088;">$start_resp</span><span style="color: #339933;">,</span> 
        <span style="color: #000088;">$end_resp</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$start_resp</span> <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;">//  Replace the tags with blank space</span>
    <span style="color: #000088;">$outcome</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;message&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$outcome</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$outcome</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/message&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$outcome</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$outcome</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$outcome</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  Echo the results.  I formatted 'error' to be red.</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p class='error&gt;<span style="color: #006699; font-weight: bold;">$outcome</span>&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<h5>Recap</h5>
<p>Well, there you have it.  Put all that code together and you should have a functioning example.</p>
<p>Of course, instead of building your own script, you could simply use the <a href="http://www.earn-web-cash.com/online-tools-design/trackback/">form I already created</a> to do this.  Or you could head over there to see how it works.</p>
<p>This is a pretty good learning activity, though.  You get to see how contexts and streams work, sending an HTTP header to get a response.</p>
<p>We also make use of the <code>urlencode()</code> function and use <code>stripos()</code> and <code>substr()</code> to do some half-assed xml parsing.  You could use a similar method for reading HTML and parsing tags.</p>
<p>Enjoy, and be sure to leave a comment if there&#8217;s something else you&#8217;d like to see explained in a tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/08/how-to-write-a-php-script-to-send-a-trackback/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Trackbacks &#8211; Remote Commenting on Blogs</title>
		<link>http://www.earn-web-cash.com/web-design-guides/trackbacks/</link>
		<comments>http://www.earn-web-cash.com/web-design-guides/trackbacks/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 23:27:30 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Sundry Musings]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[trackback]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/web-design-guides/trackbacks/</guid>
		<description><![CDATA[The topic for today is trackbacks. What are they? What do they do? How do I use one? Trackbacks are strange things. Blogs all over the internet have them enabled, but I’d bet a lot of the blog owners don’t have a clue what they are. Here&#8217;s the short version. Trackbacks are citation systems for [...]]]></description>
			<content:encoded><![CDATA[<p>The topic for today is trackbacks. What are they? What do they do? How do I use one?</p>
<p>Trackbacks are strange things. Blogs all over the internet have them enabled, but I’d bet a lot of the blog owners don’t have a clue what they are.</p>
<p>Here&#8217;s the short version.  Trackbacks are citation systems for blogs.  Trackbacks are also a system for remote commenting.</p>
<p>That&#8217;s how they&#8217;re typically explained, but that doesn&#8217;t help a whole lot, now does it?</p>
<p>So here are a few questions answered to get you started on understanding the trackback.</p>
<ul>
<li><a href="http://www.earn-web-cash.com/web-design-guides/trackbacks/what-is-a-trackback-and-what-does-it-do/">What is a trackback and what does it do?</a></li>
<li><a href="http://www.earn-web-cash.com/web-design-guides/trackbacks/do-all-blogs-support-trackbacks/">Do all blogs support trackbacks?</a></li>
<li><a href="http://www.earn-web-cash.com/web-design-guides/trackbacks/why-would-i-want-to-create-a-trackback/">How can I create a trackback</a></li>
<li><a href="http://www.earn-web-cash.com/web-design-guides/trackbacks/how-can-i-send-a-trackback/">Why would I want to create a trackback?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/web-design-guides/trackbacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Added First Online Tool</title>
		<link>http://www.earn-web-cash.com/2008/01/06/added-first-online-tool/</link>
		<comments>http://www.earn-web-cash.com/2008/01/06/added-first-online-tool/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 20:25:20 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Online Tools]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[trackback]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/06/added-first-online-tool/</guid>
		<description><![CDATA[I just created the &#8220;Online Tools&#8221; page section, and added the first tool to the list. What is it? It&#8217;s a form that let&#8217;s you send a trackback to a blog from any website. It might sound silly, but trust me&#8230; it&#8217;s not. I faced this problem with another website of mine (Babel). I was [...]]]></description>
			<content:encoded><![CDATA[<p>I just created the <a href="http://www.earn-web-cash.com/online-tools-design/">&#8220;Online Tools&#8221;</a> page section, and added the first tool to the list.</p>
<p>What is it?  It&#8217;s a <a href="http://www.earn-web-cash.com/online-tools-design/trackback/" title="Form to submit a trackback from any site">form that let&#8217;s you send a trackback</a> to a blog from any website.  It might sound silly, but trust me&#8230; it&#8217;s not.<br />
<span id="more-16"></span><br />
I faced this problem with another website of mine (<a href="http://www.teachbabel.com" title="Babel - Education Site for Teachers">Babel</a>).  I was using a CMS (cmsmadesimple) instead of a blogging platform.</p>
<p>Still, I had some blog-like posts using a module in the CMS.  I wanted to be able to trackback to someone else&#8217;s blog to signal that I was referencing their post, but there was no trackback functionality in cmsmadesimple.</p>
<p>I looked into writing a full plugin and tag for cmsmadesimple, but I decided it would be easier to just write a simple form and a script to do the work for me.  Thus, the <a href="http://www.earn-web-cash.com/online-tools-design/trackback/">trackback-via-form tool</a> was born.</p>
<p>You can <a href="http://www.earn-web-cash.com/online-tools-design/submit-trackbacks-from-any-page/">read more about trackbacks and why you need this form</a>, or just head over to the form and start submitting pings to blogs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/06/added-first-online-tool/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Free Online Tools for Web Designers</title>
		<link>http://www.earn-web-cash.com/online-tools-design/</link>
		<comments>http://www.earn-web-cash.com/online-tools-design/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 17:32:14 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Sundry Musings]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[Online]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[trackback]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/free-online-tools/</guid>
		<description><![CDATA[This is a collection of scripts and online tools that I&#8217;ve written. They&#8217;ve helped me in the past as a web designer and internet author, so chances are they might help you. Browse through and use what you need. If you have an idea for a new kind of tool that you need, and I [...]]]></description>
			<content:encoded><![CDATA[<p>This is a collection of scripts and online tools that I&#8217;ve written.  They&#8217;ve helped me in the past as a web designer and internet author, so chances are they might help you.</p>
<p>Browse through and use what you need.  If you have an idea for a new kind of tool that you need, and I could build, leave a comment.  Maybe I&#8217;ll put it on my to-do list.</p>
<h5><a href="http://www.earn-web-cash.com/online-tools-design/submit-trackbacks-from-any-page/" title="How to submit trackbacks if your website doesn't support it.">Submit Trackbacks with a Form</a></h5>
<p>Trackbacks are great, but not all blogging platforms and websites support them.  Solution?  Submit them from a third-party form &#8211; like the <a href="http://www.earn-web-cash.com/online-tools-design/trackback/" title="Form to send a trackback for you from any site">trackback-via-form tool</a> I wrote.</p>
<p>You provide all the necessary information &#8211; the trackback URI and your webpage&#8217;s information &#8211; and the script sends the trackback to your target.  Pretty nifty tool for publicizing websites that don&#8217;t have built in support for trackbacks.</p>
<h5><a href="http://www.earn-web-cash.com/online-tools-design/text-cleaner-form/">Text Cleaner Tool: Remove Newline Characters</a></h5>
<p>This is a simple tool that can come in handy for uploading articles to your own site or to article directories.  If you used hard line-breaks to format the article for print or for e-mail, you&#8217;ll need to get rid of those new-lines.  Just copy and paste into the form, and those newline characters will be a thing of the past.</p>
<p>You can access the <a href="http://www.earn-web-cash.com/online-tools-design/text-cleaner-form/">Text Cleaner Form</a> here.</p>
<h5><a href="http://www.earn-web-cash.com/online-tools-design/encode-sample-html/">Form to Encode Sample HTML for Display</a></h5>
<p>If you want to display sample HTML for the user to see, you need to jump through a few hurdles.  With <a href="http://www.earn-web-cash.com/online-tools-design/encode-sample-html/html-encoding-form/">this tool</a>, you can copy and paste HTML into the textarea, hit submit, and get text that has all of the special characters escaped for you.</p>
<p>Copy and paste that on to your page, and it should appear as a perfect snippet of sample markup.  Check out the <a href="http://www.earn-web-cash.com/online-tools-design/encode-sample-html/html-encoding-form/">HTML encoding form here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/online-tools-design/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Trackback-via-Form Tool: Submit a Trackback</title>
		<link>http://www.earn-web-cash.com/online-tools-design/trackback/</link>
		<comments>http://www.earn-web-cash.com/online-tools-design/trackback/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 17:24:10 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Sundry Musings]]></category>
		<category><![CDATA[anywhere]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[trackback]]></category>
		<category><![CDATA[uri]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/trackback-via-form-tool-submit-a-trackback/</guid>
		<description><![CDATA[So you want to submit a trackback, but you&#8217;re website or blogging platform doesn&#8217;t support it? No problem! Fill out the form below, and we&#8217;ll do the trackbacking for you.The Trackback URI comes from the website you&#8217;re sending the ping to. The other sections are pretty self-explanatory &#8211; describe the post you&#8217;re trackbacking from. If [...]]]></description>
			<content:encoded><![CDATA[
<p>So you want to submit a trackback, but you&#8217;re website or blogging platform doesn&#8217;t support it?  No problem!</p>

<p>Fill out the form below, and we&#8217;ll do the trackbacking for you.The Trackback URI comes from the website you&#8217;re sending the ping to.  The other sections are pretty self-explanatory &#8211; describe the post you&#8217;re trackbacking from.</p>

<p>If you want to test it out, trackback to this page and watch the magic work.  You should get a response if it works, or an error message if something goes wrong.</p>

<form id="trackback-form" method=post action="http://www.earn-web-cash.com/online-tools-design/trackback/"><fieldset id="trackback">
<label for="trackback-uri">Trackback URI:</label>
<input id="trackback-uri" name="trackback-uri" value="" type="text" /><label for="title">Post Title:</label>
<input id="title" name="title" type="text" value="" /><label for="url">Post URL:</label>
<input id="url" name="url" value="" type="text" /><label for="excerpt">Excerpt:</label>
<input id="excerpt" name="excerpt" value="" type="text" /><label for="blog">Blog Name:</label>
<input id="blog" name="blog" value="" type="text" /><label for="submit"></label>
<input value="Send Trackback Ping" name="submit" id="submit" type="submit" /> </fieldset></form>]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/online-tools-design/trackback/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Submit Trackbacks From Any Page and Non-Blog Platforms</title>
		<link>http://www.earn-web-cash.com/online-tools-design/submit-trackbacks-from-any-page/</link>
		<comments>http://www.earn-web-cash.com/online-tools-design/submit-trackbacks-from-any-page/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 16:30:40 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Sundry Musings]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[trackback]]></category>
		<category><![CDATA[Traffic]]></category>
		<category><![CDATA[uri]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/submit-trackbacks-from-any-page/</guid>
		<description><![CDATA[Trackbacks are a great way to publicize your blog or website. They allow you to ping a person&#8217;s blog, say &#8220;Hey, I&#8217;m talking about you!&#8221; and leave a message. These trackback pings will show up in the target post&#8217;s comment section, and sometimes the author will separate trackbacks out to show at the beginning of [...]]]></description>
			<content:encoded><![CDATA[<p>Trackbacks are a great way to publicize your blog or website.  They allow you to ping a person&#8217;s blog, say &#8220;Hey, I&#8217;m talking about you!&#8221; and leave a message.</p>
<p>These trackback pings will show up in the target post&#8217;s comment section, and sometimes the author will separate trackbacks out to show at the beginning of the list.  Although they won&#8217;t always get you search engine ju-ju, thanks to rel=nofollow, they are a great way to get <strong>people</strong> to come to your website.</p>
<h5>Why Trackback If the Search Engine Doesn&#8217;t Care?</h5>
<p>I know that every time I get a trackback to one of my websites, I immediately check out the source.  To some extent I want to check for spam, but I&#8217;m also concerned with, &#8220;Who&#8217;s this new guy talking to me?&#8221;</p>
<p>When I&#8217;m viewing another person&#8217;s blog, I also usually follow the trackbacks if I was interested in the original post.  I rarely click on the typical name-link included in a comment, though.</p>
<p>The trackback signals to both the target website&#8217;s author and to its readers that this comment has something worth while for them to read.  So often they&#8217;ll click the link and see what you have to say.</p>
<h5>Ok, How Do I Send a Trackback?</h5>
<p>Well, if you&#8217;re using a standard blogging platform like WordPress, it&#8217;s pretty easy.  At the bottom of your post editing screen, you&#8217;ll probably see a space to enter a trackback URI.  This is the link from the original website that you send the trackback ping to.</p>
<p>Just enter the URI in your editor, and you&#8217;re all set.  The problem, though, is that not every blogging platform supports sending trackbacks.  You might also want to send a trackback from a non-blog website, if you&#8217;ve added some content that speaks to the original post.</p>
<p>Enter the <a href="http://www.earn-web-cash.com/online-tools-design/trackback/" title="Form to send a trackback for you from any site">trackback-via-form tool</a>.  <a href="http://www.earn-web-cash.com/online-tools-design/trackback/" title="Form to send a trackback for you from any site">This form</a> will do all the work for you.  Enter the necessary information (Trackback URI, your page&#8217;s title, your page&#8217;s URL, an excerpt of your page, and your blog name), and hit submit.</p>
<p>You should see a response with either an &#8220;All clear!  Trackback was sent successfully.&#8221; or some kind of error message.</p>
<p>Enjoy, and good luck trackbacking.  Test it out by sending a trackback to this page or the form&#8217;s page.</p>
<p>If you&#8217;re done with the trackback form, why don&#8217;t you go back and browse through some other <a href="http://www.earn-web-cash.com/online-tools-design/" title="Free Online Tools for Web Designers">online tools?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/online-tools-design/submit-trackbacks-from-any-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

