<?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>Lonnie Knows Everything &#187; PHP</title>
	<atom:link href="http://blog.oneduality.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.oneduality.com</link>
	<description>So you don&#039;t have to!</description>
	<lastBuildDate>Wed, 30 Nov 2011 19:37:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Post to twitter using PHP without using oauth or the API</title>
		<link>http://blog.oneduality.com/2011/03/15/post-to-twitter-using-php-without-using-oauth-or-the-api/</link>
		<comments>http://blog.oneduality.com/2011/03/15/post-to-twitter-using-php-without-using-oauth-or-the-api/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 18:54:42 +0000</pubDate>
		<dc:creator>Lonnie</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Nerd Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Curl]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://blog.oneduality.com/?p=1167</guid>
		<description><![CDATA[So you want to post twitter updates and perhaps follow people using PHP but you&#8217;re annoyed with that oauth implementation because it makes life difficult? no problem I&#8217;ve constructed a class that implements two functions, posting a status update and following an author .. This is purely for educational purposes and is intended to demonstrate [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to post twitter updates and perhaps follow people using PHP but you&#8217;re annoyed with that oauth implementation because it makes life difficult? no problem</p>
<p>I&#8217;ve constructed a class that implements two functions, posting a status update and following an author .. This is purely for educational purposes and is intended to demonstrate the art of page scraping as well as the use of CURL for posting and retrieving data, I would of course never personally recommend using the code because I&#8217;m sure it&#8217;s some sort of violation of their TOS ;) so yeah.. don&#8217;t do it! ;) ;)</p>
<p>Some important things to note:</p>
<p>1. This will break if twitter changes their html up too much<br />
2. This is probably a violation, so if you do use it, use it reasonably .. don&#8217;t submit a million requests per second, throttle it down =)<br />
3. You&#8217;re using it at your own risk<br />
4. It will post status updates as if you posted from a mobile device ( Ie. Mobile Web )</p>
<p><strong>DOWNLOAD: </strong><a href="http://blog.oneduality.com/tweeter.zip" target="_blank">Click to download example and class file</a></p>
<p><strong>USAGE:</strong></p>
<blockquote><p>include(&#8220;tweeter.php&#8221;);</p>
<p>$tweeter = new tweeter();<br />
$tweeter-&gt;login($username,$password);<br />
$tweeter-&gt;post_tweet(&#8220;Hey, this is cool!&#8221;);<br />
$tweeter-&gt;folllow(&#8220;oneduality&#8221;);</p></blockquote>
<p><strong>Contents of tweeter.php:</strong></p>
<blockquote>
<pre>class tweet {
    var $user;
    var $token='';
    var $ch='';
    var $action='';

    // Logs in to twitter
    function login($user,$pass) {
        $this-&gt;user = $user;

        // Initialize CH
        if (!function_exists("curl_init")) die("This requires the CURL module, please install CURL for php.");
        $this-&gt;ch = curl_init();

        // Parse the login form
        curl_setopt($this-&gt;ch, CURLOPT_URL, "https://mobile.twitter.com/session/new");
        curl_setopt($this-&gt;ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($this-&gt;ch, CURLOPT_FAILONERROR, 1);
        curl_setopt($this-&gt;ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($this-&gt;ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($this-&gt;ch, CURLOPT_TIMEOUT, 5);
        curl_setopt($this-&gt;ch, CURLOPT_COOKIEJAR, $this-&gt;user . ".txt");
        curl_setopt($this-&gt;ch, CURLOPT_COOKIEFILE, $this-&gt;user . ".txt");
        curl_setopt($this-&gt;ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 ");
        $page = curl_exec($this-&gt;ch);

        $page = stristr($page, "
<div class="signup-body">");
        preg_match("/form action=\"(.*?)\"/", $page, $this-&gt;action);
        preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $this-&gt;token);

        // Login and get your home page
        $strpost = "authenticity_token=".urlencode($this-&gt;token[1])."&amp;username=".urlencode($user)."&amp;password=".urlencode($pass);
        curl_setopt($this-&gt;ch, CURLOPT_URL, $this-&gt;action[1]);
        curl_setopt($this-&gt;ch, CURLOPT_POSTFIELDS, $strpost);
        $page = curl_exec($this-&gt;ch);

        // Verify that we logged in ok
        preg_match("/\
<div class="\&quot;warning\&quot;\">(.*?)\&lt;\/div\&gt;/", $page, $warning);
        if (isset($warning[1])) return $warning[1];
        $page = stristr($page,"
<div class="tweetbox">");
        preg_match("/form action=\"(.*?)\"/", $page, $this-&gt;action);
        preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $this-&gt;authenticity_token);
    }

    function post_tweet($status) {

        // Set status
        $tweet['display_coordinates']='';
        $tweet['in_reply_to_status_id']='';
        $tweet['lat']='';
        $tweet['long']='';
        $tweet['place_id']='';
        $tweet['text']=$status;
        $ar = array("authenticity_token" =&gt; $this-&gt;token[1], "tweet"=&gt;$tweet);
        $data = http_build_query($ar);
        curl_setopt($this-&gt;ch, CURLOPT_URL, $this-&gt;action[1]);
        curl_setopt($this-&gt;ch, CURLOPT_POSTFIELDS, $data);
        $page = curl_exec($this-&gt;ch);

        return true;
    }

    function follow($author_name) {

        $action = "http://mobile.twitter.com/$author_name/follow";
        $ar = array("authenticity_token" =&gt; $this-&gt;token[1], "tweet"=&gt;$tweet, 'last_url'=&gt;'/$author_name', );
        $data = http_build_query($ar);
        curl_setopt($this-&gt;ch, CURLOPT_URL, $action);
        curl_setopt($this-&gt;ch, CURLOPT_POSTFIELDS, $data);
        $page = curl_exec($this-&gt;ch);

        return true;
    }
}</div>
</div>
</div>
</pre>
</blockquote>
<h4>Incoming search terms:</h4><ul><li>curl login to twitter without Oauth</li><li>php post to twitter 2011</li><li>tweeter api php oauth</li><li>post to twitter without oauth</li><li>twitter php api</li><li>Posting to Twitter using PHP</li><li>post to twitter php 2011</li><li>php post twitter without api</li><li>How to post to twitter with php and Curl without oAuth</li><li>post twitter via php 2011</li></ul><!-- SEO SearchTerms Tagging 2 plugin took -0.228 ms -->]]></content:encoded>
			<wfw:commentRss>http://blog.oneduality.com/2011/03/15/post-to-twitter-using-php-without-using-oauth-or-the-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple domain names in Joomla 1.0.x</title>
		<link>http://blog.oneduality.com/2009/01/14/multiple-domain-names-in-joomla-10x/</link>
		<comments>http://blog.oneduality.com/2009/01/14/multiple-domain-names-in-joomla-10x/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 15:48:38 +0000</pubDate>
		<dc:creator>Lonnie</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.oneduality.com/?p=32</guid>
		<description><![CDATA[If you&#8217;re running Joomla 1.0.x and you&#8217;ve tried to get more than one domain name pointing to it, then you&#8217;ve no doubt realized that it doesn&#8217;t really work out that well. I mean, the site will come up but the moment you click a link you will be sent directly to the original site url. [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re running Joomla 1.0.x and you&#8217;ve tried to get more than one domain name pointing to it, then you&#8217;ve no doubt realized that it doesn&#8217;t really work out that well. I mean, the site will come up but the moment you click a link you will be sent directly to the original site url.</p>
<p>Well this aims to give you a quick, easy solution!</p>
<p><span id="more-32"></span></p>
<p>The first thing you&#8217;ll want to do is open up your <strong>configuration.php</strong> file in your editor of choice.</p>
<p>Look for the variable &#8220;$mosConfig_live_site&#8221;, this is no doubt configured to your current web site address! and this is what is causing your problem.  We&#8217;ll be changing it to this:</p>
<p>$mosConfig_live_site = &#8220;http://&#8221; . $_SERVER['HTTP_HOST'];</p>
<p>This will pull the site&#8217;s URL out of an environment variable on the server! This means that no matter what URL is used to get to your site, Joomla will automatically set $mosConfig_live_site to match.</p>
<p>This solution works in the world of Linux and Apache, if you&#8217;re running Joomla in a windows environment and this doesn&#8217;t work, I suggest going to your Joomla control panel and looking at System info -&gt; php info &#8230; You&#8217;re trying to find a variable that contains the website name without http:// in front of it .. once you find something, adjust the code above! if you find one that has http:// in front of it, then you can further adjust the code to suit your needs.</p>
<p>Have fun!</p>
<h4>Incoming search terms:</h4><ul><li>configuration php multiple domain joomla</li><li>joomla multiple domains</li><li>multiple domains joomla</li><li>Joomla multiple domain names</li><li>joomla several domains</li><li>multiple domain joomla</li><li>Multiple Domains in joomla</li><li>jessica karp</li><li>change url in Joomla multi domain</li><li>one joomla website multiple domains</li></ul><!-- SEO SearchTerms Tagging 2 plugin took 0.382 ms -->]]></content:encoded>
			<wfw:commentRss>http://blog.oneduality.com/2009/01/14/multiple-domain-names-in-joomla-10x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

