<?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>BncApps &#187; PHP</title>
	<atom:link href="http://bncapps.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://bncapps.com</link>
	<description>Open Source Applications and General Technology Blog</description>
	<lastBuildDate>Sat, 11 Dec 2010 23:48:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Download a file in PHP</title>
		<link>http://bncapps.com/download-a-file-in-php/</link>
		<comments>http://bncapps.com/download-a-file-in-php/#comments</comments>
		<pubDate>Sun, 02 May 2010 00:31:02 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=530</guid>
		<description><![CDATA[Here is a simple function to download a file in PHP and save it on your web server. I needed this for another project, so I coded it and decided to post it up here! The $file variable is the url to the file And the $savefile variable is where it should be saved on [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple function to download a file in PHP and save it on your web server. I needed this for another project, so I coded it and decided to post it up here!<br />
The $file variable is the url to the file<br />
And the $savefile variable is where it should be saved on the server (path and file name)</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_file<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span>, <span style="color: #0000ff;">$savefile</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0000ff;">$out</span> = <a href="http://www.php.net/fopen"><span style="color: #000066;">fopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$savefile</span>, <span style="color: #ff0000;">'wb'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$out</span> == <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      <a href="http://www.php.net/print"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Error opening file&lt;br&gt;&quot;</span>;
      <a href="http://www.php.net/exit"><span style="color: #000066;">exit</span></a>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">$ch</span> = curl_init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_FILE, <span style="color: #0000ff;">$out</span><span style="color: #66cc66;">&#41;</span>;
    curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_HEADER, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
    curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_URL, <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span>;
    curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span><span style="color: #66cc66;">&#41;</span>;
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> curl_error <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$ch</span><span style="color: #66cc66;">&#41;</span>;
    curl_close<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/download-a-file-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter API &#8211; Creating lists with PHP and cURL</title>
		<link>http://bncapps.com/twitter-api-creating-lists-with-php-and-curl/</link>
		<comments>http://bncapps.com/twitter-api-creating-lists-with-php-and-curl/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 13:33:50 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=508</guid>
		<description><![CDATA[I needed to be able to create Twitter lists for my Tweet Large project. So, here is a method i made to do this. It is in PHP and requires the cURL library. Simply pass the new list name, as well as the username and password and the list will be created. &#160; public function [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to be able to create Twitter lists for my <a href="http://bncapps.com/tweetlarge-current-project/">Tweet Large</a> project. So, here is a method i made to do this. It is in PHP and requires the cURL library. Simply pass the new list name, as well as the username and password and the list will be created.</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> createList<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$listname</span>=<span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">$username</span>=<span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">$password</span>=<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$listname</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; !<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$username</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; !<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$password</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #0000ff;">$url</span> = <span style="color: #ff0000;">'http://api.twitter.com/1/'</span>.<span style="color: #0000ff;">$username</span>.<span style="color: #ff0000;">'/lists.xml'</span>;
<span style="color: #0000ff;">$curl_handle</span> = curl_init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span>, CURLOPT_URL, <span style="color: #ff0000;">&quot;$url&quot;</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span>, CURLOPT_CONNECTTIMEOUT, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span>, CURLOPT_RETURNTRANSFER, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span>, CURLOPT_POST, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span>, CURLOPT_POSTFIELDS, <span style="color: #ff0000;">&quot;name=$listname&quot;</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span>, CURLOPT_USERPWD, <span style="color: #0000ff;">$username</span>.<span style="color: #ff0000;">&quot;:&quot;</span>.<span style="color: #0000ff;">$password</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$buffer</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span><span style="color: #66cc66;">&#41;</span>;
curl_close<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curl_handle</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/twitter-api-creating-lists-with-php-and-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TweetLarge &#8211; Current Project</title>
		<link>http://bncapps.com/tweetlarge-current-project/</link>
		<comments>http://bncapps.com/tweetlarge-current-project/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 02:20:46 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[twitter followers]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=506</guid>
		<description><![CDATA[First of all, I am sorry for this being the only post within TWO months! Here is the story: Over the past 2 months, and for the next little while I have been working on a project with a team. The site is Twitter based and its purpose is to give you free Twitter followers. [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, I am sorry for this being the only post within TWO months! Here is the story:</p>
<p>Over the past 2 months, and for the next little while I have been working on a project with a team. The site is Twitter based and its purpose is to give you free <a href="http://tweetlarge.com?id=2">Twitter followers</a>.</p>
<p>The front end is simple, complete the three steps: Login, choose a Tweet, and send. Each Tweet you send will score you 100 followers. You can do this up to 10 times. After this time, you can still Tweet to enter the lottery. Each Tweet gives you one entry into the lottery, you can join once per hour. There are 6 prizes given out daily, with the top prize being 500 followers!</p>
<p>The back end is not so simple looking as the front end. Since this is a programming site I will go into some detail of how the core works, but I can not provide any code examples.</p>
<p>When you request for your followers, you are added to a job quene. This script is load balanced and there are 3 servers that check the quene. If they see a new job to process, and the job is 5 minutes old it will take it and mark it as being in process. When the job runs, it will validate that you have the Tweet still on your Twitter page. If not, it will send you an @reply notifying you. (I will post up a guide on Tweeting through PHP real soon - I was sure I had already done so, but apparently not)</p>
<p>It would then cycle through our accounts and follow you, ensuring that you get the exact number of followers you deserve. If while following you our system detects any of our accounts as being inactive, we will credit everybody who that account followed. This way you are guaranteed the right number of followers, and wont suffer a loss.</p>
<p>Our servers also run a validation script to clean up the dead accounts from our database, this is run while there are no following jobs active. See <a href="http://bncapps.com/php-verifying-twitter-credentials-using-fsock/">Verifying Twitter Credentials In PHP</a>.</p>
<p>Well thats all for now. So why dont you go ahead and <a href="http://tweetlarge.com?id=2">Get Twitter followers</a>.</p>
<p><a href="http://www.TweetLarge.com?id=2">http://TweetLarge.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/tweetlarge-current-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mass Tweet Lottery &#8211; Now with Twitter oAuth!</title>
		<link>http://bncapps.com/mass-tweet-lottery-now-with-twitter-oauth/</link>
		<comments>http://bncapps.com/mass-tweet-lottery-now-with-twitter-oauth/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 04:33:24 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=495</guid>
		<description><![CDATA[Today I was learning how to use the Twitter oAuth API. If you dont know what this is, it is a way to allow third party sites access to your Twitter account to send Tweets and read your data, without giving your actual password! I worked to get this implemented in to the Mass Tweet [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was learning how to use the Twitter oAuth API. If you dont know what this is, it is a way to allow third party sites access to your Twitter account to send Tweets and read your data, without giving your actual password! I worked to get this implemented in to the Mass Tweet Lottery, now you can choose to login with your real user name and password, or using oAuth where you sign in through Twitter.</p>
<p>Now for those who were worried about joining it because it required storing your password, there is no need to worry.</p>
<p>Everyone can join, as long as you have atleast 100 followers! Join now:<br />
<a href="http://MassTweetLottery.com">http://MassTweetLottery.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/mass-tweet-lottery-now-with-twitter-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter Account Validation Script</title>
		<link>http://bncapps.com/twitter-account-validation-script/</link>
		<comments>http://bncapps.com/twitter-account-validation-script/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 03:42:48 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[twitter account validation]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=491</guid>
		<description><![CDATA[I have many Twitter accounts I need to manage, and recently a few of them have been hacked, or the passwords got changed for a few hours, then changed back. Instead of finding out too late when this happens, I decided to write a script that checks them, and emails me notifying me if the [...]]]></description>
			<content:encoded><![CDATA[<p>I have many Twitter accounts I need to manage, and recently a few of them have been hacked, or the passwords got changed for a few hours, then changed back. Instead of finding out too late when this happens, I decided to write a script that checks them, and emails me notifying me if the passwords are invalid. </p>
<p>I use my function from this post: <a href="http://bncapps.com/php-verifying-twitter-credentials-using-fsock/">Verifying Twitter Credentials using fsock</a></p>
<p>See the full article for more!<br />
<span id="more-491"></span><br />
<center><script type="text/javascript"><!--
google_ad_client = "pub-5038888073735758";
google_ad_slot = "9247579423";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #0000ff;">$emailaddress</span> = <span style="color: #ff0000;">'youremail@domain.com'</span>;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> verifyCredentials<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$username</span>, <span style="color: #0000ff;">$password</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #0000ff;">$out</span>=<span style="color: #ff0000;">&quot;GET http://twitter.com/account/verify_credentials.xml HTTP/1.1<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Host: twitter.com<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Authorization: Basic &quot;</span>.<a href="http://www.php.net/base64_encode"><span style="color: #000066;">base64_encode</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$username</span>.<span style="color: #ff0000;">&quot;:&quot;</span>.<span style="color: #0000ff;">$password</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Content-type: application/x-www-form-urlencoded<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Connection: Close<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<span style="color: #0000ff;">$fp</span> = <a href="http://www.php.net/fsockopen"><span style="color: #000066;">fsockopen</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'twitter.com'</span>, <span style="color: #cc66cc;">80</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span>, <span style="color: #0000ff;">$out</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$buf</span> = <a href="http://www.php.net/fread"><span style="color: #000066;">fread</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span>, <span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #0000ff;">$pos</span> = <a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$buf</span>,<span style="color: #ff0000;">'Could not'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pos</span> === <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">1</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">$u</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'Twitteruser1'</span>;
<span style="color: #0000ff;">$p</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'twitterpass1'</span>;
<span style="color: #0000ff;">$u</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'Twitteruser2'</span>;
<span style="color: #0000ff;">$p</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'twitterpass2'</span><span style="color: #ff0000;">';
$errors = 0;
$total = count($u);
for ($i = 0; $i&lt;$total; $i++){
$TwitterValid = new TwitterValid($u[$i],$p[$i]);
$validation = verifyCredentials($u[$i],$p[$i]);
if ($validation == 0){
$v[$i] = '</span>INVALID<span style="color: #ff0000;">';
$errors = 1;
}else{
$v[$i] = '</span>VALID<span style="color: #ff0000;">';
}
}
if ($errors == 1){
for ($i = 0; $i&lt;$total; $i++){
	$summary = $summary. &quot;$u[$i] - $v[$i]<span style="color: #000099; font-weight: bold;">\n</span>&quot;;
}
$headers .= &quot;MIME-Version: 1.0<span style="color: #000099; font-weight: bold;">\n</span>&quot;;
$headers = '</span>From: Validation@<span style="color: #ff0000;">'.preg_replace('</span><span style="color: #808080; font-style: italic;">#^www\.#', '', strtolower($_SERVER['SERVER_NAME']))  . &quot;\n&quot;;</span>
<span style="color: #0000ff;">$headers</span> .= <span style="color: #ff0000;">&quot;Content-Type: text/plain<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
<span style="color: #0000ff;">$mail_Subject</span> = <span style="color: #ff0000;">&quot;Twitter Accounts - Invalid!&quot;</span>;
<span style="color: #0000ff;">$mail_Body</span> = <span style="color: #ff0000;">&quot;At least one account showed up with an invalid password!
Summary:
$summary
&quot;</span>;
<a href="http://www.php.net/mail"><span style="color: #000066;">mail</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$emailaddress</span>, <span style="color: #0000ff;">$mail_Subject</span>, <span style="color: #0000ff;">$mail_Body</span>,<span style="color: #0000ff;">$headers</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>So basically, you would add an aditional<br />
$u[0] = 'Twitteruser1';<br />
$p[0] = 'twitterpass1';<br />
For each account, obviously incrementing the array size.</p>
<p>I use cronjobs each hour to run this script and it emails me only if any of the accounts appear invalid.</p>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/twitter-account-validation-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Verifying Twitter Credentials using fsock</title>
		<link>http://bncapps.com/php-verifying-twitter-credentials-using-fsock/</link>
		<comments>http://bncapps.com/php-verifying-twitter-credentials-using-fsock/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 23:12:14 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[verify twitter credentials in php]]></category>
		<category><![CDATA[verify twitter credentials using fsock]]></category>
		<category><![CDATA[verify twitter password in php]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=488</guid>
		<description><![CDATA[For all of my Twitter web applications, I have had to verify that the provided login details for a Twitter account are valid. I have used this method for The Re-Revtwter Bot, Twitter Train - TwooTwoo and more recently, The Mass Tweet Lottery. Without being able to validate the credentials, floods of accounts could be [...]]]></description>
			<content:encoded><![CDATA[<p>For all of my Twitter web applications, I have had to verify that the provided login details for a Twitter account are valid. I have used this method for <a href="http://bncapps.com/the-re-revtwter-bot-make-even-more-money-on-twitter/">The Re-Revtwter Bot</a>, <a href="http://bncapps.com/twootwoo-get-twitter-followers-fast-and-free/">Twitter Train - TwooTwoo</a> and more recently, <a href="http://bncapps.com/mass-tweet-lottery/">The Mass Tweet Lottery</a>.<br />
Without being able to validate the credentials, floods of accounts could be added, and the dont even necessarly have to be theirs.</p>
<p>I have provided a simple function in PHP using fsocks, which will work on 99.99% of servers. The current available methods require cURL, which not all servers support. Read the full article for the function and usage!<br />
<span id="more-488"></span><br />
Provided below is the function to verify.</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> verifyCredentials<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$username</span>, <span style="color: #0000ff;">$password</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #0000ff;">$out</span>=<span style="color: #ff0000;">&quot;GET http://twitter.com/account/verify_credentials.xml HTTP/1.1<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Host: twitter.com<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Authorization: Basic &quot;</span>.<a href="http://www.php.net/base64_encode"><span style="color: #000066;">base64_encode</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$username</span>.<span style="color: #ff0000;">&quot;:&quot;</span>.<span style="color: #0000ff;">$password</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Content-type: application/x-www-form-urlencoded<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
  .<span style="color: #ff0000;">&quot;Connection: Close<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<span style="color: #0000ff;">$fp</span> = <a href="http://www.php.net/fsockopen"><span style="color: #000066;">fsockopen</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'twitter.com'</span>, <span style="color: #cc66cc;">80</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span>, <span style="color: #0000ff;">$out</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$buf</span> = <a href="http://www.php.net/fread"><span style="color: #000066;">fread</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span>, <span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #0000ff;">$pos</span> = <a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$buf</span>,<span style="color: #ff0000;">'Could not'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pos</span> === <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">1</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>It returns 1 if valid, 0 if invalid.<br />
You can do a simple check like this:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$twitterusername</span> = <span style="color: #ff0000;">'Myusername'</span>;
<span style="color: #0000ff;">$twitterpassword</span> = <span style="color: #ff0000;">'mypass123'</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>verifyCredentials<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$twitterusername</span>,<span style="color: #0000ff;">$twitterpassword</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'INVALID LOGIN DETAILS!'</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'VALID!'</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Any questions/problems? Just ask.</p>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/php-verifying-twitter-credentials-using-fsock/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Re-RevTwter Bot &#8211; Make even more money on Twitter</title>
		<link>http://bncapps.com/the-re-revtwter-bot-make-even-more-money-on-twitter/</link>
		<comments>http://bncapps.com/the-re-revtwter-bot-make-even-more-money-on-twitter/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 17:21:21 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[auto retweet]]></category>
		<category><![CDATA[make money on twitter]]></category>
		<category><![CDATA[retweet twitter]]></category>
		<category><![CDATA[revtwt]]></category>
		<category><![CDATA[twitter money]]></category>
		<category><![CDATA[twitter retweeter]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=467</guid>
		<description><![CDATA[RevTwt is a service that posts advertisements on your Twitter accounts that makes you money when people visit them. You can have up to 10 Twitter accounts added to your RevTwt account and have them set to automatically post advertisements. Sounds like a way to make easy money, dosnt it? Well, it is, but atleast [...]]]></description>
			<content:encoded><![CDATA[<div><a href="http://revtwt.com/index.php?id=31611"><img src="http://revtwt.com/images/TwtAd_referral01.jpg" alt="" /></a></div>
<p><a rel="nofollow" href="http://revtwt.com/index.php?id=31611">RevTwt</a> is a service that posts advertisements on your Twitter accounts that makes you money when people visit them. You can have up to 10 Twitter accounts added to your RevTwt account and have them set to automatically post advertisements. Sounds like a way to make easy money, dosnt it? Well, it is, but atleast 80% of your tweets must be real, as in not advertisements. So that means you will have to spend time each day to make each of your accounts look real.</p>
<p>What if there was a way to <strong>automatically</strong> do this by grabbing a random message said by somebody on Twitter within the past few minutes, and retweeting it. And, not only that, it will only grab the tweets on twitter that contain a TinyUrl link, it will then replace that one with a link created through RevTwts service that will contain advertisements. So, if somebody clicks the link, it will bring them to a landing page with advertisements, any of those clicks earns money to your RevTwt account, and a few seconds later they are redirected to the real link that they wanted.<br />
Check out the full article to find out more!<br />
<span id="more-467"></span></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5038888073735758";
google_ad_slot = "9247579423";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<h1 style="text-align: center;">Introducing the Re-RevTwt Bot!</h1>
<h2 style="text-align: center;"><span style="color: #0000ff;">What it does</span></h2>
<p>This tool allows you to make your RevTwt.com bots FULLY automated. The rules of the site state that atleast 80% of your Tweets MUST BE REAL, meaning not advertisements. This forces you to make real posts multiple times per day on all your accounts. What if there was a way to do this automated, and make more money while doing so?</p>
<p>The RevTwt network has a way to shorten urls and when people go to them there are landing pages with more ads that make you money.</p>
<p>My tool will grab a random Tweet on Twitter, where somebody used a TinyURL link, it will split it up to grab the TinyUrl link and it will then reinsert it in place. It will retweet it through your account. So it will retweet an existing Tweet, which must be of some interest to people as they are spreading it, with your advertisements!</p>
<h2 style="text-align: center;"><span style="color: #0000ff;">Why is it free?</span></h2>
<p>The reason it is free is because there is a chance of my RevTwt advertising ID being used instead of yours. There is a 1/3 (subject to change) chance that my ads will be placed in instead. That still leaves all of you with the priority and having a higher chance....and hey, its  better than still updating it manually.</p>
<p>Also, if you like you can pay just $8 and get a private ID that you pass to the url and it will ALWAYS use your publisher information, to maximize the profits.</p>
<h2 style="text-align: center;"><span style="color: #0000ff;">Usage:</span></h2>
<p>http://www.TwooTwoo.com/rerevtwt/index.php?u=TWITTERUSERNAME&amp;p=TWITTERPASSWORD&amp;ru=REVTWTUSER&amp;rk=REVTWTKEY</p>
<p>So you pass the following information to index.php:<br />
u - Twitter username<br />
p - Twitter Password<br />
ru - RevTwt user ID<br />
rk - RevTwt user key</p>
<p>Just login to your RevTwt account, click ShortURL then on the right side click the api and apply to get your key (you get it instantly) This can be done automated through CronJobs or Windows task scheduler.</p>
<h2 style="text-align: center;"><span style="color: #0000ff;">Example:</span></h2>
<p>If my twitter username was Bncapps and my password was 12345<br />
And then I applied anf got my userid, being 18595 and my user key, lets say mykey444</p>
<p>This is how the url would look:</p>
<p>http://www.TwooTwoo.com/rerevtwt/index.php?u=bncapps&amp;p=12345&amp;ru=18595&amp;rk=mykey444</p>
<p>So you can simply set up a cronjob to call this, lets say once every 3 hours or so. Spamming it will only get your RevTwt account banned!<br />
Cron job example:</p>
<p><strong>curl "http://www.TwooTwoo.com/rerevtwt/index.php?u=bncapps&amp;p=12345&amp;ru=18595&amp;rk=mykey444"</strong><br />
<strong>No account information is stored on the server at all. </strong></p>
<p>This service is active and free. For only $8, you can upgrade and get a special code that will allow you to use this service, with your advertisements being shown 100% of the time. If you are interested, just contact me.</p>
<p>If you have any questions relating to the usage of this, just ask.</p>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/the-re-revtwter-bot-make-even-more-money-on-twitter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tinyby.com &#8211; The API to generate and resolve short links</title>
		<link>http://bncapps.com/tinyby-com-the-api-to-generate-and-resolve-short-links/</link>
		<comments>http://bncapps.com/tinyby-com-the-api-to-generate-and-resolve-short-links/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 04:33:43 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[file_get_contents($url);]]></category>
		<category><![CDATA[generate shortened url]]></category>
		<category><![CDATA[grabbing content in php]]></category>
		<category><![CDATA[how to shorten a url in php]]></category>
		<category><![CDATA[php api]]></category>
		<category><![CDATA[php file get contents]]></category>
		<category><![CDATA[php string replace]]></category>
		<category><![CDATA[php str_replace]]></category>
		<category><![CDATA[shorten my url]]></category>
		<category><![CDATA[shortening urls]]></category>
		<category><![CDATA[shrink a link]]></category>
		<category><![CDATA[tinyby]]></category>
		<category><![CDATA[tinyurl]]></category>

		<guid isPermaLink="false">http://bncapps.com/?p=456</guid>
		<description><![CDATA[My project Tinyby.com has been in slow development. Recently an API system has been added to allow scripts to make use of shortening URLS, proxified or not, and with or without a custom short name, and even resolving them. The API resolves around the php function file_get_contents, which was previously used here: Website parsing for [...]]]></description>
			<content:encoded><![CDATA[<p>My project <a href="http://www.TinyBy.com">Tinyby.com</a> has been in slow development. Recently an API system has been added to allow scripts to make use of shortening URLS, proxified or not, and with or without a custom short name, and even resolving them. </p>
<p>The API resolves around the php function file_get_contents, which was previously used here: <a href="http://bncapps.com/website-parsing-for-specific-data/">Website parsing for specific data</a>.</p>
<p>Although all the instructions for making use of the API can be found <a href="http://www.tinyby.com/developers.php">on the developers page</a>, I will go over it in more detail here. </p>
<p>These functions are currently for PHP only, but they will be moved to other programming languages soon. Or you can learn how to <a href="http://bncapps.com/java-downloading-a-website/">Download the contents of a website in Java</a> and try to build an API in Java for yourself!</p>
<p>More in the full article...</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-5038888073735758";
google_ad_slot = "9247579423";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center><br />
<span id="more-456"></span><br />
The first function allows creation of the shortened URL. The function only has one required parameter and only returns one thing, the shortened URL or the error messages.</p>
<p>To start, here is the function:</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> createRedirect<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$url</span>,<span style="color: #0000ff;">$short</span>=<span style="color: #ff0000;">''</span>,<span style="color: #0000ff;">$proxified</span>=<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$url</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&amp;'</span>,<span style="color: #ff0000;">'(*)'</span>,<span style="color: #0000ff;">$url</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0000ff;">$shorturl</span>= <a href="http://www.php.net/file_get_contents"><span style="color: #000066;">file_get_contents</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://tinyby.com/api.php?u='</span>.<span style="color: #0000ff;">$url</span>.<span style="color: #ff0000;">'&amp;s='</span>.<span style="color: #0000ff;">$short</span>.<span style="color: #ff0000;">'&amp;p='</span>.<span style="color: #0000ff;">$proxified</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$shorturl</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>api.php on my server recognizes not to do anything if it recieves nothing, or a blank string for $short or $proxified.</p>
<p>To tell the URL to become proxified, you can pass that parameter a '1', 'yes' or a 'true'.</p>
<p>One of the first lines within the function is this:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$url</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&amp;'</span>,<span style="color: #ff0000;">'(*)'</span>,<span style="color: #0000ff;">$url</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>What this does is convert all the & symbols within the link we are passing to a special symbol we know will never appear in the url. Then, on the server side, the symbol is replaced back with & symbols. Without this, the shortened URLS will be truncated at the &. </p>
<p>Through doing file_get_contents with the appropriate parameters, the server will simply print out the URL. There will be no formatting on the page, just plain text, allowing it to return just the shortened url.</p>
<p>Usage of this function is as easy as copying it within your php code, and doing something similar to the following:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$mynewlink</span> = createRedirect<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://BlindingProxy.com'</span>,<span style="color: #ff0000;">'blinding'</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$mynewlink</span>;
&nbsp;</pre>
<p>As you can see, that will create a redirect to BlindingProxy.com with the short url blinding. If the short url is taken, a random one will be generated and returned.<br />
Below are some of the errors that can be returned from the server<br />
<code><br />
<strong>Errors:</strong></p>
<p><strong>A URL was not entered. Please try again</strong> --> Nothing was passed through the function to the server</p>
<p><strong>Invalid Proxy Short</strong> -> Only A-Z, 0-9, dashes and underscores are allowed</p>
<p><strong>Proxy short can be a max of 30 characters</strong> --> Self explanatory</p>
<p><strong>URL can not exceed 2000 characters!</strong> --> Also self explanitory<br />
</code></p>
<p>The last function simply returns the full url from the shortened one.</p>
<pre class="php">&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> resolveRedirect<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$url</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$resolvedurl</span>= <a href="http://www.php.net/file_get_contents"><span style="color: #000066;">file_get_contents</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://tinyby.com/apiget.php?u='</span>.<span style="color: #0000ff;">$url</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$resolvedurl</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>All it needs is the one parameter and it will return the full url.</p>
<p>The api will be extended later on to be able to see if a url is proxified or not, as well as seeing traffic stats for links and whatever other new features are released.</p>
<p><a href="http://www.tinyby.com">Tinyby.com - Proxified url redirection</a></p>
<p>Questions? Comments? Ask below! </p>
]]></content:encoded>
			<wfw:commentRss>http://bncapps.com/tinyby-com-the-api-to-generate-and-resolve-short-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
