<?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>Miss E .D .C &#187; flickr api authentication</title>
	<atom:link href="http://blog.ethelcofie.com/tag/flickr-api-authentication/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ethelcofie.com</link>
	<description>Thoughts on Software development,IT Business Consultancy,New Technologies and other random stuff i have done</description>
	<lastBuildDate>Mon, 23 May 2011 14:29:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Flickr API: How to perform Authentication using PHP</title>
		<link>http://blog.ethelcofie.com/2008/05/19/flickr-api-how-to-perform-authenticating-using-php/</link>
		<comments>http://blog.ethelcofie.com/2008/05/19/flickr-api-how-to-perform-authenticating-using-php/#comments</comments>
		<pubDate>Mon, 19 May 2008 13:32:26 +0000</pubDate>
		<dc:creator>ethelcofie</dc:creator>
				<category><![CDATA[Development Articles]]></category>
		<category><![CDATA[flickr api]]></category>
		<category><![CDATA[flickr api authentication]]></category>

		<guid isPermaLink="false">http://etheldcofie.wordpress.com/?p=8</guid>
		<description><![CDATA[I presented this at Brighton BArCamp3 download power point //1.Create a login link $secret_key=&#8217;secret key&#8217;; $params = array( &#8216;api_key&#8217;=&#62; &#8216;api_key&#8217;, &#8216;perms&#8217; =&#62; &#8216;write&#8217;); $encoded_param = array(); //1.a Encode and organize authentication parameters foreach($params as $key =&#62; $value) { $encoded_params[] = urlencode($key).&#8217;=&#8217;.urlencode($value); } //1b Create the api signature :an md5 of the parameters in alphabetic order [...]]]></description>
			<content:encoded><![CDATA[<p>I presented this at Brighton BArCamp3 <a href="http://blog.ethelcofie.com/wp-content/uploads/2008/09/flickr-php2.ppt" target="_blank">download power point</a></p>
<p><strong>//1.Create a login link</strong></p>
<p>$secret_key=&#8217;secret key&#8217;;</p>
<p>$params = array(<br />
&#8216;api_key&#8217;=&gt; &#8216;api_key&#8217;,<br />
&#8216;perms&#8217; =&gt; &#8216;write&#8217;);</p>
<p>$encoded_param = array();</p>
<p><strong>//1.a Encode and organize authentication parameters</strong></p>
<p>foreach($params as $key =&gt; $value)<br />
{<br />
$encoded_params[] = urlencode($key).&#8217;=&#8217;.urlencode($value);<br />
}</p>
<p><strong>//1b Create the api signature :an md5 of the parameters in alphabetic order</strong></p>
<p><strong></strong><br />
$apisig=md5($secret_key.&#8217;api_key&#8217;.$params['api_key'].&#8217;perms&#8217;.$params['perms']);</p>
<p><strong>//1.c append api signature to url</strong></p>
<p>$url =&#8221;<a href="http://flickr.com/services/auth/?">http://flickr.com/services/auth/?&#8221;.</a></p>
<p>implode(&#8216;&amp;&#8217;,$encoded_params).&#8221;&amp;api_sig=&#8221;.$apisig;</p>
<p>header(&#8216;Location:&#8217;.$url); &#8211;&gt;<strong>This will then redirect back to your call back url and include a frob value</strong></p>
<p><strong>//2.Get and use frob to retrive authentication token</strong></p>
<p><strong>//2.a Get frob from url </strong></p>
<p>if ($_REQUEST['frob'])<br />
{<br />
<em>//using  php_serial paramater serial to retrieve the format in serialized data structure<br />
</em> $frobparams = array(<br />
&#8216;api_key&#8217;=&gt; &#8216;api_key&#8217;,<br />
&#8216;frob&#8217; =&gt; &#8216;frob&#8217; ,<br />
&#8216;method&#8217; =&gt; &#8216;flickr.auth.getToken&#8217;,<br />
&#8216;format&#8217; =&gt; &#8216;php_serial&#8217;);</p>
<p>$encoded_param = array();</p>
<p>foreach($frobparams as $key =&gt; $value)<br />
{<br />
$encoded_params[] = urlencode($key).&#8217;=&#8217;.urlencode($value);<br />
}<br />
$url = &#8220;<a href="http://api.flickr.com/services/rest/?">http://api.flickr.com/services/rest/?&#8221;.implode(&#8216;&amp;&#8217;</a>, $encoded_params);</p>
<p><strong>//2.bCreate the api signature :an md5 of the parameters in alphabetic order</strong></p>
<p>$apisigfrob=md5(</p>
<p>$secret_key.</p>
<p>&#8216;api_key&#8217;.  $frobparams ['api_key'].</p>
<p style="text-align:left;">&#8216;format&#8217;.$frobparams ['format'].</p>
<p style="text-align:left;">&#8216;frob&#8217;.$frobparam['frob'].</p>
<p style="text-align:left;">&#8216;method&#8217;.$frobparams['method']);</p>
<p><strong></strong></p>
<p><strong>//2.c Construct url to auth.getToken</strong></p>
<p>$url=$url.&#8221;&amp;api_sig=&#8221;.$apisigfrob;</p>
<p><strong></strong></p>
<p><strong>// 2.d Get url response/contents</strong><br />
$rsp = file_get_contents($url);</p>
<p>$rsp_obj = unserialize($rsp);</p>
<p>$details=$rsp_obj;</p>
<p><strong></strong></p>
<p><strong>//2.e Glean Auth Token from $details</strong></p>
<p>if($details[stat]==&#8217;ok&#8217;)<br />
{<br />
echo  $details['auth']['token']['_content'];<br />
}<br />
else<br />
{</p>
<p>//dispaly error message if there is a problem<br />
echo  $details [message]    ;</p>
<p>}</p>
<p>}</p>
<p><strong>Just getting started:</strong> The Authentication Token can then be ussed as part of the parameter for a method call</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ethelcofie.com/2008/05/19/flickr-api-how-to-perform-authenticating-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

