<?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>Web Designer - Defining the internet through beautiful design &#187; PHP</title>
	<atom:link href="http://www.webdesignermag.co.uk/category/tutorials/php-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdesignermag.co.uk</link>
	<description>Web Design for real people</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:00:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Add a Facebook image gallery to your site</title>
		<link>http://www.webdesignermag.co.uk/tutorials/facebook-image-gallery/</link>
		<comments>http://www.webdesignermag.co.uk/tutorials/facebook-image-gallery/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 10:58:50 +0000</pubDate>
		<dc:creator>Mark Billen</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Dreamweaver]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://www.webdesignermag.co.uk/?p=7208</guid>
		<description><![CDATA[Deliver a dynamic photo gallery with  this social network-powered solution]]></description>
			<content:encoded><![CDATA[<!--facebook--><!--step1--><!--step1_2--><!--step3--><p><img class="alignnone size-full wp-image-7220" title="Add a Facebook image gallery to your site" src="http://www.webdesignermag.co.uk/wp-content/uploads/2011/09/facebook.jpg" alt="Add a Facebook image gallery to your site" width="500" height="188" /></p>
<p>tools | tech | trends: Dreamweaver, PHP, Lightbox<br />
expert: Pete Simmons</p>
<p>(This article originally appeared in Web Designer issue 183, authored by Pete Simmons (aka &#8216;Terrorfall&#8217;). You can download the associated CD project files by <a href="http://www.webdesignermag.co.uk/wp-content/uploads/2011/04/Facebook_Gallery.zip" target="_blank">clicking here</a>)</p>
<p>Following on from the Facebook news feed tutorial found in issue 181, we’ll be showing you how to use Facebook to drive a dynamic photo gallery. The gallery will update as you add photos through Facebook, and will display image comments.<br />
If you missed the previous tutorial, we’ll start from the beginning, showing you how to get your Facebook ID and get the page set up correctly. As before, you won’t need to authenticate a website visitor, as all data retrieved is publicly accessible. However, it is worth noting that you may need to authenticate if you are pulling data from a personal page, rather than a fan page.<br />
This tutorial assumes that you have a PHP environment set up that is capable of reading JSON objects. JSON functionality comes pre-packaged  with PHP version 5.2.0 and higher, but if you find that you are getting “Fatal error: Call to undefined function json_decode()”, see the following forum post: <a href="http://bit.ly/noJSON" target="_blank">http://bit.ly/noJSON</a>. It may also be worth switching hosting provider, or downloading and installing the latest version of XAMPP from <a href="http://bit.ly/getXAMPP" target="_blank">http://bit.ly/getXAMPP</a>.<br />
This tutorial will not cover adding CSS or any images, but the project contain a basic template.<br />
<strong><br />
01 Facebook page setup</strong></p>
<p><img class="alignnone size-full wp-image-7212" title="Add a Facebook image gallery to your site" src="http://www.webdesignermag.co.uk/wp-content/uploads/2011/09/step1.jpg" alt="Add a Facebook image gallery to your site" width="500" height="190" /></p>
<p>It is important to ensure your Facebook page is set up correctly, so that your website can view the data. Go to your page on Facebook, select Edit Page and ensure that there are no age or country restrictions listed under the Manage Permissions tab. Also, ensure the ‘Only admins can see this Page’ box is unchecked.</p>
<p><img class="alignnone size-full wp-image-7211" title="Add a Facebook image gallery to your site" src="http://www.webdesignermag.co.uk/wp-content/uploads/2011/09/step1_2.jpg" alt="Add a Facebook image gallery to your site" width="500" height="237" /></p>
<p><strong>02 Your page ID</strong><br />
If you’ve set up a brand new Facebook page, you won’t be able to shorten the URL yet and you will need to use the ID of your page. The easiest way to get hold of this is to click on your page’s profile picture and make a note of the numbers listed after “&amp;id=” in your address bar.</p>

					<div class="adInPost">
						<script type="text/javascript">
							GA_googleFillSlot("WD_MidPage_MPU1");
						</script>
					</div><p><strong>03 View page data</strong></p>
<p><img class="alignnone size-full wp-image-7213" title="Add a Facebook image gallery to your site" src="http://www.webdesignermag.co.uk/wp-content/uploads/2011/09/step3.jpg" alt="Add a Facebook image gallery to your site" width="500" height="239" /></p>
<p>Go to <a href="https://graph.facebook.com/terrorfall/albums" target="_blank">https://graph.facebook.com/terrorfall/albums</a> and you’ll see a JSON-encoded list of all photo albums on the terrorfall Facebook page. These are arranged from newest to oldest by default and show links to individual albums, as well as album comments. Replace “terrorfall” with your own page name or page ID to see your own.</p>
<p><strong>04 Page character setup</strong><br />
Open the template file or create a new PHP document in Dreamweaver. This is required to prevent character errors as we progress through the tutorial. By default Dreamweaver will add this in, but ensure you have the following line of code in the head section of your PHP page.</p>
<p>001 <em>&lt;meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8”/&gt;</em></p>
<p><strong>05 Import Facebook data</strong><br />
Drop down to the body section of your PHP document and open up a new section of PHP code.<br />
The following lines of code set out the page that you want to get the data from. Add this in, along with some tidy comments, replacing ‘terrorfall’ with your page name or ID.</p>
<p>001 <em>&lt;?php</em><br />
002 <em>//Set the page name or ID</em><br />
003 <em>$FBid = ‘terrorfall’;</em><br />
004 <em>//Get the contents of a Facebook page</em><br />
005 <em>$FBpage = file_get_contents(‘https://graph.facebook.com/’.$FBid.’/albums’);</em><br />
006 <em>//Interpret data with JSON </em><br />
007 <em>$photoData= json_decode($FBpage);</em><br />
008 <em>?&gt; </em> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdesignermag.co.uk/tutorials/facebook-image-gallery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Enabling single signon using Open ID login, PHP and MySQL</title>
		<link>http://www.webdesignermag.co.uk/tutorials/enabling-single-signon-using-open-id-login-php-and-mysql/</link>
		<comments>http://www.webdesignermag.co.uk/tutorials/enabling-single-signon-using-open-id-login-php-and-mysql/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 17:31:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open ID]]></category>

		<guid isPermaLink="false">http://172.25.6.102:8888/webdesigner/?p=30</guid>
		<description><![CDATA[ENABLE YOUR WEB APPLICATION FOR OPEN ID TO LET YOUR USERS LOG IN WITHOUT HAVING TO REMEMBER YET ANOTHER PASSWORD]]></description>
			<content:encoded><![CDATA[<!--open_id1--><!--tutorial1_11--><!--tutorial1_21--><p><a href="http://wp-content/uploads/2009/03/open_id1.png"><img class="alignnone size-full wp-image-40" title="Enabling single signon using Open ID login, PHP and MySQL" src="http://www.webdesignermag.co.uk/wp-content/uploads/2009/03/open_id1.png" alt="Enabling single signon using Open ID login, PHP and MySQL" /></a></p>
<p>ENABLE YOUR WEB APPLICATION FOR OPEN ID TO LET YOUR USERS LOG IN WITHOUT HAVING TO REMEMBER YET ANOTHER PASSWORD</p>
<p>Think about the number of username and password combinations you have to remember on a daily basis &#8211; bank logins, social networking sites, Flickr, Twitter, Basecamp and so on. The more security-conscious of us will accept that using the same username and password isn&#8217;t a great idea, as if you use that combination on an untrusted site, they could use it to log in as you into everywhere else. We would rather be storing more useful things than passwords in our brains, so we&#8217;re very happy that Open ID is becoming a popular way for websites to authenticate users. So what is an Open ID? You can get an Open ID by various methods; the simplest is to choose a trusted Open ID provider and sign up with them. You might also find that one of the sites you already sign into is an Open ID provider &#8211; AOL, LiveJournal and most recently Yahoo! can all act as your Open ID. You will then be given a username, something like http://yourname.myOpen ID.com. When you log in on an Open ID-enabled site, you simply enter this URL into their login box. The site will then redirect out to your Open ID provider where you will log in and the provider then checks that you are happy to give the other site your details. You will then be sent back to the website and are logged in. The benefits to users are that they don&#8217;t need to remember lots of different sets of login details, and can also keep the actual password details on one trusted site. For the site owner, you don&#8217;t need to store password details on your site and deal with forgotten passwords and so on. If you have built a password login system for a site before, then enabling Open ID just means a small shift in thinking &#8211; for storing a username and password on your site and writing a script to check them, to firing out a request to an external site and getting information back as to whether your user is logged in or not. You can still tie any information specific to your site to a user, by linking that information to their Open ID in your database. So now you know what Open ID is, this tutorial will have a look at how you might enable your site for Open ID logins. We&#8217;ll be using PHP and MySQL, although the principles are the same whichever language you choose.</p>
<p><strong>1. Get your Open ID</strong></p>
<p><a href="http://wp-content/uploads/2009/03/tutorial1_11.jpg"><img class="alignnone size-full wp-image-43" title="Enabling single signon using Open ID login, PHP and MySQL" src="http://www.webdesignermag.co.uk/wp-content/uploads/2009/03/tutorial1_11.jpg" alt="Enabling single signon using Open ID login, PHP and MySQL" /></a></p>
<p>The first step is to have an Open ID to use to test your sign-on. If you already have an Open ID or are signed up for a site that gives you one, then you are all set. Otherwise, sign up at a provider such as www.myopenid.com and get your own Open ID URL.</p>
<p><strong>2. Download the PHP class</strong></p>
<p><a href="http://wp-content/uploads/2009/03/tutorial1_21.jpg"><img class="alignnone size-full wp-image-44" title="Enabling single signon using Open ID login, PHP and MySQL" src="http://www.webdesignermag.co.uk/wp-content/uploads/2009/03/tutorial1_21.jpg" alt="Enabling single signon using Open ID login, PHP and MySQL" /></a></p>

					<div class="adInPost">
						<script type="text/javascript">
							GA_googleFillSlot("WD_MidPage_MPU1");
						</script>
					</div><p>We will use a PHP class in order to simplify the process of communicating with the Open ID provider. The class we are going to use is the Simple Open ID Class that is available from www.phpclasses.org/browse/package/3290.html. The version of the class we have used is available in the code sample, however, if you are going to use this in a live application, check the site for any updates to it. In the zip that you have downloaded, the file you will need is class.openid.v2.php. Save this into your site, naming it anything you like.</p>
<p><strong>3. Create a form</strong></p>
<p>In a new PHP file, add a form; all we need is a field for the user to enter their Open ID URL and a Submit button. Set the form to post back to itself for this example. We’ve also added a link to myopenid.com so the user can go and get an Open ID if they don’t have one yet.</p>
<p style="padding-left: 30px;"><em>&lt;form action=”index.php” method=”post”&gt;<br />
&lt;h1&gt;Login with your openID&lt;/h1&gt;<br />
&lt;div&gt;<br />
&lt;div&gt;&lt;label for=”openid”&gt;Your OpenID&lt;/label&gt;&lt;input<br />
ype=”text” name=”openid_url” id=”openid” class=”text” /&gt;<br />
&lt;input type=”submit” name=”login” value=”Login” class=”btn”<br />
/&gt;&lt;/div&gt;<br />
&lt;p&gt;&lt;a href=”http://www.myopenid.com/”&gt;Get an OpenID&lt;/a&gt;&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;/form&gt;</em></p>
<p><strong>4. Posting the form</strong></p>
<p>We now need to deal with what happens when the user posts the form containing their Open ID. At the very top of this script inside PHP tags, include the class we downloaded earlier and create a new instance of that class.</p>
<p style="padding-left: 30px;"><em>require(‘class.openid.v2.php’);<br />
if ($_POST) {<br />
$openid = new OpenIDService();</em></p>
<p><strong>5. Set up the request</strong></p>
<p>In addition to checking whether the user is valid, we can ask the Open ID server to send us back some information about the user, such as their email address, full name and gender. The user needs to have already entered this information into their profile and agree to send it to you when they get to the Open ID site. The following lines of code set the user’s identity (this is the URL they entered into the text box), the site that is asking to be authorised, some required fields that we need and some optional fields.</p>
<p style="padding-left: 30px;"><em>$openid-&gt;SetIdentity($_POST[‘Open ID_url’]);<br />
$openid-&gt;SetTrustRoot(‘http://’ . $_SERVER[“HTTP_HOST”]);<br />
$openid-&gt;SetRequiredFields(array(‘email’,’fullname’));<br />
$openid-&gt;SetOptionalFields(array(‘dob’,’gender’,’country’));</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdesignermag.co.uk/tutorials/enabling-single-signon-using-open-id-login-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

