<?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>Open Source Web &#187; api</title>
	<atom:link href="http://www.open-source-web.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.open-source-web.com</link>
	<description>Your open source for Development and Design</description>
	<lastBuildDate>Sun, 08 Jan 2012 10:21:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP Spam Blocker</title>
		<link>http://www.open-source-web.com/php/php-spam-blocker/</link>
		<comments>http://www.open-source-web.com/php/php-spam-blocker/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 15:18:14 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[spam bot]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=187</guid>
		<description><![CDATA[If you have a problem with Bot user&#8217;s and spam in WordPress the best solution is setting up Akismet. It&#8217;s an easy to use plug-in that just needs an API key. For Bespoke websites there isn&#8217;t a one click plug-in but there is a super easy to use Bot database called BotScout with an API [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a problem with Bot user&#8217;s and spam in WordPress the best solution is setting up Akismet. It&#8217;s an easy to use plug-in that just needs an API key.</p>
<p>For Bespoke websites there isn&#8217;t a one click plug-in but there is a super easy to use Bot database called BotScout with an API that only requires a <a href="http://botscout.com/getkey.htm" target="_blank">key</a> and CURL.</p>
<p>Botscout is compatible a range of off the shelf PHP systems such as PHPBB.</p>
<p>The following function will return</p>
<ul>
<li>0 = Not a bot</li>
<li>1 = Is a bot</li>
<li>2 = Failed to check for some reason</li>
</ul>
<pre>function testSpam($XIP,$XUSER,$XMAIL){  /// IP,username,email
$botdata='';
$APIKEY = 'PxX19wq5uJWiIL8'; // your optional API key
$XMAIL =urlencode($XMAIL); // make the url compliant with urlencode()
$apiquery = "http://botscout.com/test/?multi&amp;mail=$XMAIL&amp;ip=$XIP&amp;key=$APIKEY"; // testing for an email address and IP

if(function_exists('file_get_contents')){
$returned_data = file_get_contents($apiquery);    // Use file_get_contents
}else{
$ch = curl_init($apiquery);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$returned_data = curl_exec($ch);
curl_close($ch);
}

if($returned_data==''){// sanity check
return 2;
}

$botdata = explode('|', $returned_data); // take the returned value and parse it (standard API, not XML)

if(substr($returned_data, 0,1) == '!'){// if the first character is an exclamation mark, an error has occurred
return 2;
}

if($botdata[3] &gt; 0 || $botdata[5] &gt; 0){  /// it must be spam bot
return 1;
}else{
return 0;
}

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/php-spam-blocker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Charts Example</title>
		<link>http://www.open-source-web.com/php/google-charts-example/</link>
		<comments>http://www.open-source-web.com/php/google-charts-example/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 18:14:03 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=117</guid>
		<description><![CDATA[API&#8217;s are becoming more popular on the web as many of the big online companies such as Google, Yahoo and Facebook offer there own open source code for web developers to use freely and easily. To begin with I am going to go through how to use the Charts Basics API from Google. This is [...]]]></description>
			<content:encoded><![CDATA[<p>API&#8217;s are becoming more popular on the web as many of the big online companies such as Google, Yahoo and Facebook offer there own open source code for web developers to use freely and easily.</p>
<p><img src="http://chart.apis.google.com/chart?chs=250x100&amp;chd=t:10,80,35,10&amp;cht=lc&amp;chl=wk1|wk2|wk3|wk4" alt="Google Charts Basics" /></p>
<p>To begin with I am going to go through how to use the Charts Basics API from Google. This is an extremely easy one to start off with as you don&#8217;t require an API key or to install anything, you don&#8217;t even need a dynamic server side script to get some nice results.</p>
<p>For this example I am going to jazz it up with a bit of PHP using an associative array but you can easily replace this with a database or XML feed.</p>
<p>To call a chart we use the query string linking to the API which will end up looking something like this.</p>
<pre id="line1">&lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"http://chart.apis.google.com/chart?chs=250x100&amp;amp;chd=t:10,80,35,10&amp;amp;cht=lc&amp;amp;chl=wk1|wk2|wk3|wk4"
</span><span class="attribute-name">alt</span>=<span class="attribute-value">"Sample chart" </span><span class="error"><span class="attribute-name">/</span></span>&gt;</pre>
<p>To generate this dynamicaly I used the following code</p>
<pre class="php" name="code">$arr = array();

$arr['Jan']['wk1'] = 10;
$arr['Jan']['wk2'] = 80;
$arr['Jan']['wk3'] = 35;
$arr['Jan']['wk4'] = 10;

$chart= 'http://chart.apis.google.com/chart?';
$chartsize = 'chs=250x100';
$type = "cht=lc";
$vals = 'chd=t:';
$keys = 'chl=';
$alt = "January";

foreach( $arr['Jan'] as $key =&gt; $value){
	$vals .= $value.',';
	$keys .= $key.'|';
	}</pre>
<p>And Lastly to pull all the code together.</p>
<pre class="php" name="code">
&lt;img src="&lt;? echo $chart;?&gt;
&lt;? echo $chartsize;?&gt;
&amp;amp;&lt;? echo substr("$vals", 0, -1);?&gt;
&amp;amp;&lt;? echo $type;?&gt;
&amp;amp;&lt;? echo substr("$keys", 0, -1);?&gt;"
alt="Sample chart" /&gt;
</pre>
<p>To develop this example further use the official documentation available here <a title="Google Chart Basic" rel="nofollow" href="http://code.google.com/apis/chart/" target="_blank">Google Chart Basic</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/google-charts-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

