<?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>Matt [Danger] &#187; Perl</title>
	<atom:link href="http://mattdanger.net/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattdanger.net</link>
	<description>One step closer to world domination</description>
	<lastBuildDate>Thu, 06 May 2010 21:31:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Facebook-Status-2.0 announced!</title>
		<link>http://mattdanger.net/2009/02/facebook-status-20-announced/</link>
		<comments>http://mattdanger.net/2009/02/facebook-status-20-announced/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 18:33:01 +0000</pubDate>
		<dc:creator>Matt Danger</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[status]]></category>

		<guid isPermaLink="false">http://mattdanger.net/?p=155</guid>
		<description><![CDATA[I have updated my original Facebook status script to work with Facebook 2.0.
Why is this interesting? Until recently the Facebook Developer Platform didn&#8217;t allow the changing of user status messages. This does and can be implemented in other utilities, which I may do in the future. Enjoy!
]]></description>
			<content:encoded><![CDATA[<p>I have <a href="http://mattdanger.net/2008/11/update-your-facebook-status-from-the-command-line/">updated my original Facebook status script</a> to work with Facebook 2.0.</p>
<p>Why is this interesting? Until <a href="http://www.allfacebook.com/2009/02/facebook-opens-status-api-say-goodbye-to-twitter/">recently</a> the Facebook Developer Platform didn&#8217;t allow the changing of user status messages. This does and can be implemented in other utilities, which I may do in the future. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://mattdanger.net/2009/02/facebook-status-20-announced/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update Your Facebook Status from the Command Line</title>
		<link>http://mattdanger.net/2008/11/update-your-facebook-status-from-the-command-line/</link>
		<comments>http://mattdanger.net/2008/11/update-your-facebook-status-from-the-command-line/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 18:07:17 +0000</pubDate>
		<dc:creator>Matt Danger</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[status]]></category>

		<guid isPermaLink="false">http://mattdanger.net/?p=23</guid>
		<description><![CDATA[The Facebook Developer Platform doesn&#8217;t give us the ability to set a user&#8217;s status so I decided to write my own method that would allow Facebook users to update their status messages without having to log into the website. 
The first version that I wrote in 2006 was a little complicated. The script had to [...]]]></description>
			<content:encoded><![CDATA[<p>The Facebook <a href="http://developer.facebook.com/">Developer Platform</a> doesn&#8217;t give us the ability to set a user&#8217;s status so I decided to write my own method that would allow Facebook users to update their status messages without having to log into the website. </p>
<p>The first version that I wrote in 2006 was a little complicated. The script had to connect to several Facebook pages and collect cookies and challenge codes that were necessary to login and update the user&#8217;s status.</p>
<p>Facebook changed their login and status update mechanisms in version 2.0 breaking my original script. I&#8217;ve rewritten it to work with Facebook 2.0. It is now actually shorter because Facebook uses the user&#8217;s homepage as the central information area. </p>
<p>Any feedback is welcome. I plan to implement this in other utilities soon. Enjoy!</p>
<p><i>Updated on May 6, 2010 to version 2.1</i></p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#===============================================================================</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Facebook status script v2.1</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This script allows you to update your Facebook status from the shell.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Copyright (C) 2010 Matt West &lt;matt at mattdanger dot net&gt;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This program is free software: you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;"># it under the terms of the GNU General Public License as published by</span>
<span style="color: #666666; font-style: italic;"># the Free Software Foundation, either version 3 of the License, or</span>
<span style="color: #666666; font-style: italic;"># (at your option) any later version.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;"># GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># For a copy of the GNU General Public License visit &lt;http://www.gnu.org/licenses/&gt;.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#===============================================================================</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Be sure you have installed the LWP and Crypt::SSLeay packages from CPAN</span>
<span style="color: #000000; font-weight: bold;">use</span> LWP;
<span style="color: #000000; font-weight: bold;">use</span> HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Cookies</span>;
<span style="color: #000000; font-weight: bold;">use</span> Term<span style="color: #339933;">::</span><span style="color: #006600;">ReadKey</span>;
<span style="color: #000000; font-weight: bold;">use</span> strict;
&nbsp;
<span style="color: #666666; font-style: italic;"># General vars</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$login</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$password</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$status</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$auth_key</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$user_agent</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6&quot;</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@header</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="">'Referer'</span> <span style="color: #339933;">=&gt;</span> <span style="">'http://www.facebook.com/'</span><span style="color: #339933;">,</span> 
               <span style="">'User-Agent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$user_agent</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cookie_jar</span> <span style="color: #339933;">=</span> HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Cookies</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span>
                file <span style="color: #339933;">=&gt;</span> <span style="">'cookies.dat'</span><span style="color: #339933;">,</span>
                autosave <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
                ignore_discard <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$browser</span> <span style="color: #339933;">=</span> LWP<span style="color: #339933;">::</span><span style="color: #006600;">UserAgent</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span>;
<span style="color: #0000ff;">$browser</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">cookie_jar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cookie_jar</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;"># Get login information &amp; the status message to send.</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Facebook login name: &quot;</span>;
<span style="color: #0000ff;">$login</span> <span style="color: #339933;">=</span> &lt;&gt;; <span style="color: #000066;">chomp</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$login</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Password: &quot;</span>;
ReadMode<span style="color: #009900;">&#40;</span><span style="">'noecho'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #0000ff;">$password</span> <span style="color: #339933;">=</span> ReadLine<span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span>; <span style="color: #000066;">chomp</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$password</span><span style="color: #009900;">&#41;</span>; ReadMode 0;
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Your status (Facebook appears to have a 232 character limit): &quot;</span>;
<span style="color: #0000ff;">$status</span> <span style="color: #339933;">=</span> &lt;&gt;; <span style="color: #000066;">chomp</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$status</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Sending... &quot;</span>;
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#================================================</span>
<span style="color: #666666; font-style: italic;"># Login and get auth key</span>
<span style="color: #666666; font-style: italic;">#================================================</span>
&nbsp;
<span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$browser</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">post</span><span style="color: #009900;">&#40;</span><span style="">'https://login.facebook.com/login.php?m&amp;next=http%3A%2F%2Fm.facebook.com%2Fhome.php'</span><span style="color: #339933;">,</span> 
                           <span style="color: #009900;">&#91;</span><span style="">'email'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$login</span><span style="color: #339933;">,</span>
                            <span style="">'pass'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$password</span><span style="color: #339933;">,</span>
                            <span style="">'login'</span> <span style="color: #339933;">=&gt;</span> <span style="">'Log In'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">@header</span><span style="color: #009900;">&#41;</span>;
<span style="color: #0000ff;">$cookie_jar</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">extract_cookies</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$response</span> <span style="color: #009900;">&#41;</span>;
<span style="color: #0000ff;">$cookie_jar</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">save</span>;
<span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$browser</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get</span><span style="color: #009900;">&#40;</span><span style="">'http://m.facebook.com/a/home.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">@header</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$auth_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">content</span>;
<span style="color: #0000ff;">$auth_key</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\n//g</span>;
<span style="color: #0000ff;">$auth_key</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^.*name=&quot;post_form_id&quot; value=&quot;//</span>;
<span style="color: #0000ff;">$auth_key</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/&quot;.*$//</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">#================================================</span>
<span style="color: #666666; font-style: italic;"># Submit the status update</span>
<span style="color: #666666; font-style: italic;">#================================================</span>
&nbsp;
<span style="color: #0000ff;">@header</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="">'Referer'</span> <span style="color: #339933;">=&gt;</span> <span style="">'http://m.facebook.com/a/home.php'</span><span style="color: #339933;">,</span> 
           <span style="">'User-Agent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$user_agent</span><span style="color: #339933;">,</span> 
           <span style="">'Host'</span> <span style="color: #339933;">=&gt;</span> <span style="">'m.facebook.com'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$browser</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">post</span><span style="color: #009900;">&#40;</span><span style="">'http://m.facebook.com/a/home.php?re974fcaf&amp;refid=7&amp;rbb94a931'</span><span style="color: #339933;">,</span> 
                           <span style="color: #009900;">&#91;</span><span style="">'fb_dtsg'</span> <span style="color: #339933;">=&gt;</span> <span style="">'jYNZj'</span><span style="color: #339933;">,</span>
                            <span style="">'post_form_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$auth_key</span><span style="color: #339933;">,</span>
                            <span style="">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$status</span><span style="color: #339933;">,</span>
                            <span style="">'update'</span> <span style="color: #339933;">=&gt;</span> <span style="">'Share'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">@header</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;"># Did we do good here?</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">content</span> eq <span style="">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Done!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;An error occurred while setting your profile status.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Now that we're done we can delete the cookies.dat file.</span>
<span style="color: #000066;">exec</span><span style="color: #009900;">&#40;</span><span style="">'rm cookies.dat'</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mattdanger.net/2008/11/update-your-facebook-status-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
