Ethelcofie’s How To Articles

September 22, 2008

Life Hacks

Filed under: Experiences — ethelcofie @ 8:21 pm
Tags: , , , , ,

Suggestions……

In need of quick design for a website, if you are like me and you probably developing the website as a favour to a friend or family member but don’t have enough time for drudging out designs your best bet is a free online CSS templates that you can download and personalize for use:

http://www.freecsstemplates.org/

http://www.freecsstemplates.com/

http://www.free-css.com/

Else if you need to put together a simple a quick and easy website which you give over to user to take control of the content then your easiest bet is using word press as a Content Management System Mark Kirby has an excellent tutorial on his website http://mark-kirby.co.uk/2008/wordpress-as-a-cms-talk-and-sample-code/

If you want to add an album to your website but don’t have the space or bandwidth I suggest use online photo social sites like and Flickr and use the API’s to retrieve images on demand Or just hotlink from your Facebook albums. A bit dodgy but it works!

I wrote a tutorial on how to use flickr API which I presented at Bar Camp Brighton 3 https://etheldcofie.wordpress.com/2008/05/19/flickr-api-how-to-perform-authenticating-using-php/

If you need to knock out your own custom social netwrok for your friends, family or people with similar interest( chocolate loving geeks perhaps !) then use Ning.com. It is great platform that allows you to create your own social network and even register a domain that points to your customized social network.

This section will be updated as often as i can with short cuts and life hacks… watch this space

Advertisements

May 19, 2008

Flickr API: How to perform Authentication using PHP

Filed under: Development Articles — ethelcofie @ 1:32 pm
Tags: ,

I presented this at Brighton BArCamp3 download power point

//1.Create a login link

$secret_key=’secret key’;

$params = array(
‘api_key’=> ‘api_key’,
‘perms’ => ‘write’);

$encoded_param = array();

//1.a Encode and organize authentication parameters

foreach($params as $key => $value)
{
$encoded_params[] = urlencode($key).’=’.urlencode($value);
}

//1b Create the api signature :an md5 of the parameters in alphabetic order


$apisig=md5($secret_key.’api_key’.$params[‘api_key’].’perms’.$params[‘perms’]);

//1.c append api signature to url

$url =”http://flickr.com/services/auth/?”.

implode(‘&’,$encoded_params).”&api_sig=”.$apisig;

header(‘Location:’.$url); –>This will then redirect back to your call back url and include a frob value

//2.Get and use frob to retrive authentication token

//2.a Get frob from url

if ($_REQUEST[‘frob’])
{
//using php_serial paramater serial to retrieve the format in serialized data structure
$frobparams = array(
‘api_key’=> ‘api_key’,
‘frob’ => ‘frob’ ,
‘method’ => ‘flickr.auth.getToken’,
‘format’ => ‘php_serial’);

$encoded_param = array();

foreach($frobparams as $key => $value)
{
$encoded_params[] = urlencode($key).’=’.urlencode($value);
}
$url = “http://api.flickr.com/services/rest/?”.implode(‘&’, $encoded_params);

//2.bCreate the api signature :an md5 of the parameters in alphabetic order

$apisigfrob=md5(

$secret_key.

‘api_key’. $frobparams [‘api_key’].

‘format’.$frobparams [‘format’].

‘frob’.$frobparam[‘frob’].

‘method’.$frobparams[‘method’]);

//2.c Construct url to auth.getToken

$url=$url.”&api_sig=”.$apisigfrob;

// 2.d Get url response/contents
$rsp = file_get_contents($url);

$rsp_obj = unserialize($rsp);

$details=$rsp_obj;

//2.e Glean Auth Token from $details

if($details[stat]==’ok’)
{
echo $details[‘auth’][‘token’][‘_content’];
}
else
{

//dispaly error message if there is a problem
echo $details [message] ;

}

}

Just getting started: The Authentication Token can then be ussed as part of the parameter for a method call

Blog at WordPress.com.