<?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>Freelance PHP Developer &#187; JQuery Goodies</title>
	<atom:link href="http://freelance-php-developer.phpmysql.co.za/category/jquery-goodies/feed/" rel="self" type="application/rss+xml" />
	<link>http://freelance-php-developer.phpmysql.co.za</link>
	<description>Freelance PHP Developer &#124; South Africa</description>
	<lastBuildDate>Sat, 07 Jan 2012 06:42:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Freelance PHP Developer</title>
		<link>http://freelance-php-developer.phpmysql.co.za/2011/05/experienced-php-developer-available-for-contract-positions/</link>
		<comments>http://freelance-php-developer.phpmysql.co.za/2011/05/experienced-php-developer-available-for-contract-positions/#comments</comments>
		<pubDate>Fri, 13 May 2011 11:23:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Freelance Web Developer]]></category>
		<category><![CDATA[JQuery Goodies]]></category>
		<category><![CDATA[MySQL Tutorials]]></category>
		<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://freelance-php-developer.phpmysql.co.za/?p=108</guid>
		<description><![CDATA[ If you are looking for an experienced PHP Developer to take up you new or abandoned project , your search is over.
I am an experienced developer with my own transport and will come to you for an initial no obligation face to face meeting.
I am also considering fulltime employment with salary offers exceeding R35K.
Call  [...]


No related posts.

Related posts brought to you by <a href='http://www.wordpressconnect.net/amazonpress/'>Amazon plugin</a>.]]></description>
			<content:encoded><![CDATA[<h2><span style="color: #19d021;"><strong> If you are looking for an experienced PHP Developer to take up you new or abandoned project , your search is over.</strong></span></h2>
<h2><span style="color: #19d021;"><strong>I am an experienced developer with my own transport and will come to you for an initial no obligation face to face meeting.</strong></span></h2>
<h2><span style="color: #19d021;"><strong>I am also considering fulltime employment with salary offers exceeding R35K.</strong></span></h2>
<h2><span style="color: #19d021;"><strong>Call  / SMS me on 079 9111 855 </strong></span></h2>
<h2><span style="color: #19d021;"><strong>Email info@mydeveloper.co.za. </strong></span></h2>
<h2><span style="color: #19d021;"><strong>I will get to you as soon as possible.<br />
</strong></span></h2>
<p><span style="color: #19d021;"> </span><strong> </strong></p>
<p><strong>Brief Profile</strong></p>
<p>I am an innovative, dynamic and self-motivated web/php  developer with proven solid technical skills in programming, advanced website and web based systems development, deployment and maintenance. I am a resourceful and analytical problem solver, strategic thinker, effective communicator at all levels, both verbally and in writing. I am a natural leader with a yearning passion for quality and success and I quickly acclimatize to new environments</p>
<p><strong>Key Skills</strong></p>
<p><strong>Programming Skills: </strong>PHP,ASP, MVC Frameworks &#8211; Code Igniter , CakePHP ,SOAP , REST , HTML ,Advanced XHTML and CSS , W3C Web Standards, Jquery , Mootools ,  Javascript , JSON , Graphic design ,and Photo editing. Proficient user of Dreamweaver CS23/CS4, Photoshop CS3 , Illustrator , Fireworks ,  Dreamweaver , Contribute.</p>
<p><strong>Open Source Platforms: </strong>Joomla , Drupal , Wordpress , OsCommerce , ZenCart , CubeCart , OpenCart</p>
<p><strong>Web Servers: </strong>Apache Http Server, Apache Tomcat 4.0. , IIS</p>
<p><strong>DBMS: </strong>MySql, MS SQL,</p>
<p><strong>Analysis/Design Methodologies: </strong>UML, OOAD, Unified Modeling Process.</p>
<p><strong>If you require a PHP developer for your project<br />
</strong></p>
<p><strong>please call Mark on 079 9111 855 or email info@mydeveloper.co.za.</strong></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://www.wordpressconnect.net/amazonpress/'>Amazon plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://freelance-php-developer.phpmysql.co.za/2011/05/experienced-php-developer-available-for-contract-positions/feed/</wfw:commentRss>
		<slash:comments>207</slash:comments>
		</item>
		<item>
		<title>Facebook Connect User Authentcation</title>
		<link>http://freelance-php-developer.phpmysql.co.za/2010/06/facebook-connect-user-authentcation/</link>
		<comments>http://freelance-php-developer.phpmysql.co.za/2010/06/facebook-connect-user-authentcation/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 06:30:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Freelance Web Developer]]></category>
		<category><![CDATA[JQuery Goodies]]></category>
		<category><![CDATA[MySQL Tutorials]]></category>
		<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://freelance-php-developer.phpmysql.co.za/2010/06/facebook-connect-user-authentcation/</guid>
		<description><![CDATA[Step 1. The Setup
MySQL Table
Let’s begin by creating a database table.





CREATE TABLE `users` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `oauth_provider` varchar(10),
 `oauth_uid` text,
 `username` text,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;


CREATE TABLE `users` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `oauth_provider` varchar(10),
    `oauth_uid` text,
 [...]


No related posts.

Related posts brought to you by <a href='http://www.wordpressconnect.net/amazonpress/'>Amazon plugin</a>.]]></description>
			<content:encoded><![CDATA[<h2>Step 1. The Setup</h2>
<h3>MySQL Table</h3>
<p>Let’s begin by creating a database table.</p>
<div>
<div>
<div></div>
</div>
<ol>
<li>CREATE TABLE `users` (</li>
<li> `id` int(10) unsigned NOT NULL AUTO_INCREMENT,</li>
<li> `oauth_provider` varchar(10),</li>
<li> `oauth_uid` text,</li>
<li> `username` text,</li>
<li> PRIMARY KEY (`id`)</li>
<li>) ENGINE=MyISAM  DEFAULT CHARSET=latin1;</li>
</ol>
</div>
<pre>CREATE TABLE `users` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `oauth_provider` varchar(10),
    `oauth_uid` text,
    `username` text,
    PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;</pre>
<p>Quite simple: we will be setting up a table for user information with  id, username, first and last name, the URL to the user’s picture, and  registered date. Also, we’re adding both an <code>oauth_provider</code> and <code>oauth_uid</code> fields, to distinguish between different  third party open authentication protocols and their identifiers. For  example, let’s say that, next week, you decide that it’s a good idea to  also let Twitter users in. Easy; you just set another value to the oauth<em>provider,  and avoid duplicating oauth</em>uid values.</p>
<h3>The Facebook App</h3>
<p>Let’s begin by <a href="http://www.facebook.com/developers/createapp.php">creating a new  application</a>. Give it a name and agree to the terms and conditions.  Next, grab both the <em>API Key</em> and <em>Secret</em> in the basic  tab as shown below.</p>
<div><img src="http://s3.amazonaws.com/nettuts/708_facebook/fb_basic.png" alt="" width="600" height="235" /></div>
<p>On the canvas tab, set both the <em>Canvas URL</em> and <em>Post-Authorize  Redirect URL</em> to your localhost and path that the script will  process — something like <code>http://localhost.com/login_facebook.php?</code>.  Note the question mark at the end and the domain; both are required by  Facebook. Simply set your <code>hosts</code> file to a valid domain  name.</p>
<div><img src="http://s3.amazonaws.com/nettuts/708_facebook/fb_canvas.png" alt="" width="600" height="160" /></div>
<p>On the connect tab, set the Connect URL to the same value and set <code>localhost.com</code> (or the one you are using) as the Base Domain.</p>
<div><img src="http://s3.amazonaws.com/nettuts/708_facebook/fb_connect.png" alt="" width="600" height="180" /></div>
<p>Now save, <a href="http://github.com/facebook/php-sdk/downloads">download  the client library</a>, and unzip <code>facebook.php</code> in the <code>src</code>dir  to a new directory created in the root.</p>
<hr />
<h2>Step 2. The Callback</h2>
<p>The authentication flow has three steps:</p>
<ol>
<li>The local script generates a URL asking the user for permission</li>
<li>Facebook returns to the Canvas URL specified with a GET parameter</li>
<li>The GET parameter authenticates the session</li>
</ol>
<p>Let’s make a quick test before registering and login.</p>
<div>
<div>
<div></div>
</div>
<ol>
<li># We require the library</li>
<li>require(&#8220;facebook.php&#8221;);</li>
<li></li>
<li># Creating the facebook object</li>
<li>$facebook = new Facebook(array(</li>
<li> &#8216;appId&#8217;  =&gt; &#8216;YOUR_APP_ID&#8217;,</li>
<li> &#8217;secret&#8217; =&gt; &#8216;YOUR_APP_SECRET&#8217;,</li>
<li> &#8216;cookie&#8217; =&gt; true</li>
<li>));</li>
<li></li>
<li># Let&#8217;s see if we have an active session</li>
<li>$session = $facebook-&gt;getSession();</li>
<li></li>
<li>if(!empty($session)) {</li>
<li> # Active session, let&#8217;s try getting the user id (getUser()) and user info (api-&gt;(&#8216;/me&#8217;))</li>
<li> try{</li>
<li> $uid = $facebook-&gt;getUser();</li>
<li> $user = $facebook-&gt;api(&#8216;/me&#8217;);</li>
<li> } catch (Exception $e){}</li>
<li></li>
<li> if(!empty($user)){</li>
<li> # User info ok? Let&#8217;s print it (Here we will be adding the login and registering routines)</li>
<li> print_r($user);</li>
<li> } else {</li>
<li> # For testing purposes, if there was an error, let&#8217;s kill the script</li>
<li> die(&#8220;There was an error.&#8221;);</li>
<li> }</li>
<li>} else {</li>
<li> # There&#8217;s no active session, let&#8217;s generate one</li>
<li> $login_url = $facebook-&gt;getLoginUrl();</li>
<li> header(&#8220;Location: &#8220;.$login_url);</li>
<li>}</li>
</ol>
</div>
<pre># We require the library
require("facebook.php");

# Creating the facebook object
$facebook = new Facebook(array(
    'appId'  =&gt; 'YOUR_APP_ID',
    'secret' =&gt; 'YOUR_APP_SECRET',
    'cookie' =&gt; true
));

# Let's see if we have an active session
$session = $facebook-&gt;getSession();

if(!empty($session)) {
    # Active session, let's try getting the user id (getUser()) and user info (api-&gt;('/me'))
    try{
        $uid = $facebook-&gt;getUser();
        $user = $facebook-&gt;api('/me');
    } catch (Exception $e){}

    if(!empty($user)){
        # User info ok? Let's print it (Here we will be adding the login and registering routines)
        print_r($user);
    } else {
        # For testing purposes, if there was an error, let's kill the script
        die("There was an error.");
    }
} else {
    # There's no active session, let's generate one
    $login_url = $facebook-&gt;getLoginUrl();
    header("Location: ".$login_url);
}</pre>
<p>Now, go to <code>http://localhost.com/login_facebook.php</code>, and  let’s see what happens. If you are redirected to Facebook and requested  for permission, we are on the right track.</p>
<div><img src="http://s3.amazonaws.com/nettuts/708_facebook/fb_permission.png" alt="" width="600" height="292" /></div>
<p>However, there might be two issues. The first one: if you’re  redirected to Facebook, but it shows an error, there might be a missing  value in the configuration. Go back to your application settings and  check both the Connect and Canvas tabs and make sure the fields are ok  as described above.</p>
<p>There might be another issue, where you see an error, like “Uncaught  CurlException: 60: SSL certificate problem, verify that the CA cert is  OK.” This happens because of the CURL settings. You’ll have to open <code>facebook.php</code>,  find the makeRequest() method, and, inside the function, find this  line:</p>
<div>
<div>
<div></div>
</div>
<ol>
<li>$opts = self::$CURL_OPTS;</li>
</ol>
</div>
<pre>$opts = self::$CURL_OPTS;</pre>
<p>Immediately following it, add:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>$opts[CURLOPT_SSL_VERIFYPEER] = false;</li>
</ol>
</div>
<pre>$opts[CURLOPT_SSL_VERIFYPEER] = false;</pre>
<p>I hate hacking libraries, but I haven’t found another way. Well,  let’s continue with user registration. I’ve also added a try/catch  statement, because, if there’s an old session keys in the GET params in  the URL, the script will die with a horrible error.</p>
<hr />
<h2>Step 3. Registration and Authentication</h2>
<p>We’ll next be working with MySQL. Please note that I will not  implement a data sanitizer, since I want to keep the code as short and  on task as possible. Please keep this in mind: always sanitize your  data.</p>
<p>First, let’s connect to the database.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>mysql_connect(&#8216;localhost&#8217;, &#8216;YOUR_USERNAME&#8217;, &#8216;YOUR_PASSWORD&#8217;);</li>
<li>mysql_select_db(&#8216;YOUR_DATABASE&#8217;);</li>
</ol>
</div>
<pre>mysql_connect('localhost', 'YOUR_USERNAME', 'YOUR_PASSWORD');
mysql_select_db('YOUR_DATABASE');</pre>
<p>Now, let’s work on the <code>$session</code> conditional, in case we  have a session.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li># We have an active session; let&#8217;s check if we&#8217;ve already registered the user</li>
<li>$query = mysql_query(&#8220;SELECT * FROM users WHERE oauth_provider = &#8216;facebook&#8217; AND oauth_uid = &#8220;. $user['id']);</li>
<li>$result = mysql_fetch_array($query);</li>
<li></li>
<li># If not, let&#8217;s add it to the database</li>
<li>if(empty($result)){</li>
<li> $query = mysql_query(&#8220;INSERT INTO users (oauth_provider, oauth_uid, username) VALUES (&#8216;facebook&#8217;, {$user['id']}, &#8216;{$user['name']}&#8217;)&#8221;);</li>
<li> $query = msyql_query(&#8220;SELECT * FROM users WHERE id = &#8221; . mysql_insert_id());</li>
<li> $result = mysql_fetch_array($query);</li>
<li>}</li>
</ol>
</div>
<pre># We have an active session; let's check if we've already registered the user
$query = mysql_query("SELECT * FROM users WHERE oauth_provider = 'facebook' AND oauth_uid = ". $user['id']);
$result = mysql_fetch_array($query);

# If not, let's add it to the database
if(empty($result)){
    $query = mysql_query("INSERT INTO users (oauth_provider, oauth_uid, username) VALUES ('facebook', {$user['id']}, '{$user['name']}')");
    $query = msyql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());
    $result = mysql_fetch_array($query);
}</pre>
<p>Note that I’m querying the database, looking for <code>facebook</code> as a <code>oauth_provider</code>; it’s generally a good idea, if you  want to accept other OAuth providers (as twitter, Google Accounts, Open  ID, etc.) and a <code>oauth_uid</code>, since it’s the identifier the  provider gives to its user accounts.</p>
<p>The <code>oauth_provider</code> field could potentially lead to bad  performance if we leave it as a <code>text</code> field type. As such,  the best option is setting it to an <a href="http://dev.mysql.com/doc/refman/5.0/en/enum.html">ENUM type</a>.</p>
<p>We have now a <code>$result</code> var with the values queried from  the database. Let’s next add some sessions. Add this line at the  beginning of your script.</p>
<div>
<ol>
<li>session_start();</li>
</ol>
</div>
<pre>session_start();</pre>
<p>After the <code>empty($result)</code> conditional, append the  following:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>if(!empty($user)){</li>
<li> # &#8230;</li>
<li></li>
<li> if(empty($result)){</li>
<li> # &#8230;</li>
<li> }</li>
<li></li>
<li> # let&#8217;s set session values</li>
<li> $_SESSION['id'] = $result['id'];</li>
<li> $_SESSION['oauth_uid'] = $result['oauth_uid'];</li>
<li> $_SESSION['oauth_provider'] = $result['oauth_provider'];</li>
<li> $_SESSION['username'] = $result['username'];</li>
<li>}</li>
</ol>
</div>
<pre>if(!empty($user)){
    # ...

    if(empty($result)){
        # ...
    }

    # let's set session values
    $_SESSION['id'] = $result['id'];
    $_SESSION['oauth_uid'] = $result['oauth_uid'];
    $_SESSION['oauth_provider'] = $result['oauth_provider'];
    $_SESSION['username'] = $result['username'];
}</pre>
<p>As it makes little sense to authenticate a user who is already logged  in, just below the <code>session_start()</code> line, add:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>if(!empty($_SESSION)){</li>
<li> header(&#8220;Location: home.php&#8221;);</li>
<li>}</li>
</ol>
</div>
<pre>if(!empty($_SESSION)){
    header("Location: home.php");
}</pre>
<p>And in the scripts which require authentication, just add:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>session_start();</li>
<li>if(!empty($_SESSION)){</li>
<li> header(&#8220;Location: login_facebook.php&#8221;);</li>
<li>}</li>
</ol>
</div>
<pre>session_start();
if(!empty($_SESSION)){
    header("Location: login_facebook.php");
}</pre>
<p>And if you want to display the username, access it as an array.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>echo &#8216;Welcome &#8216; . $_SESSION['username'];</li>
<li># or..</li>
<li>echo &#8216;Welcome &#8216; . !empty($_SESSION) ? $_SESSION['username'] : &#8216;guest&#8217;;</li>
</ol>
</div>
<pre>echo 'Welcome ' . $_SESSION['username'];
# or..
echo 'Welcome ' . !empty($_SESSION) ? $_SESSION['username'] : 'guest';</pre>
<hr />
<h2>Step 4. Additional Methods</h2>
<p>Facebook has a ton of connect features, but here are four that I’ve  found to be the most useful.</p>
<h3>Legacy Methods</h3>
<p>I might be missing something, but the FQL seems more flexible and  easy than the Graph API. Fortunately, Facebook still lets developers use  it, altough with the new library, it has changed a bit.</p>
<p>If you want the user id, first name, last name, squared thumbnail for  the user picture, the biggest user picture available, and his or her  gender, you can use the <code>users.getInfo</code> method.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>$uid = $facebook-&gt;getUser();</li>
<li>$api_call = array(</li>
<li> &#8216;method&#8217; =&gt; &#8216;users.getinfo&#8217;,</li>
<li> &#8216;uids&#8217; =&gt; $uid,</li>
<li> &#8216;fields&#8217; =&gt; &#8216;uid, first_name, last_name, pic_square, pic_big, sex&#8217;</li>
<li>);</li>
<li>$users_getinfo = $facebook-&gt;api($api_call);</li>
</ol>
</div>
<pre>    $uid = $facebook-&gt;getUser();
    $api_call = array(
        'method' =&gt; 'users.getinfo',
        'uids' =&gt; $uid,
        'fields' =&gt; 'uid, first_name, last_name, pic_square, pic_big, sex'
    );
    $users_getinfo = $facebook-&gt;api($api_call);</pre>
<p>You can check <a href="http://wiki.developers.facebook.com/index.php/Users.getInfo#Response">the  full list of fields available for Users.getInfo</a>.</p>
<p>It is possible to achieve the same result, using FQL.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>$uid = $facebook-&gt;getUser();</li>
<li>$fql_query  =   array(</li>
<li> &#8216;method&#8217; =&gt; &#8216;fql.query&#8217;,</li>
<li> &#8216;query&#8217; =&gt; &#8216;SELECT uid, first_name, last_name, pic_square, pic_big, sex FROM user WHERE uid = &#8216; . $uid</li>
<li>);</li>
<li>$fql_info = $facebook-&gt;api($fql_query);</li>
</ol>
</div>
<pre>    $uid = $facebook-&gt;getUser();
    $fql_query  =   array(
        'method' =&gt; 'fql.query',
        'query' =&gt; 'SELECT uid, first_name, last_name, pic_square, pic_big, sex FROM user WHERE uid = ' . $uid
    );
    $fql_info = $facebook-&gt;api($fql_query);</pre>
<p>Here’s the <a href="http://developers.facebook.com/docs/reference/fql/">list of tables</a> which can be accessed with FQL, as well as <a href="http://developers.facebook.com/docs/reference/fql/user">the fields  available for the table users</a>.</p>
<h3>Extended Permissions</h3>
<p>Facebook provides applications with some interaction with the user’s  data – just as long as it’s authorized. With the old API, the  authorization for additional permissions was exclusively available for  the Javascript SDK (altough I’m not quite sure). With the new API, we  can easily redirect the user to an authorization dialog in Facebook, and  return to our site after the access is either granted or denied.</p>
<p>In the following example, we will be redirecting a user to authorize  posts status updates, photos, videos and notes, the user’s real email  address, birthday and access to photos and videos.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>$uid = $facebook-&gt;getUser();</li>
<li></li>
<li># req_perms is a comma separated list of the permissions needed</li>
<li>$url = $facebook-&gt;getLoginUrl(array(</li>
<li> &#8216;req_perms&#8217; =&gt; &#8216;email,user_birthday,status_update,publish_stream,user_photos,user_videos&#8217;</li>
<li>));</li>
<li>header(&#8220;Location: {$url} &#8220;);</li>
</ol>
</div>
<pre>$uid = $facebook-&gt;getUser();

# req_perms is a comma separated list of the permissions needed
$url = $facebook-&gt;getLoginUrl(array(
    'req_perms' =&gt; 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'
));
header("Location: {$url} ");</pre>
<p>Here’s <a href="http://developers.facebook.com/docs/authentication/permissions">a  full list of permissions</a>. Note that you can specify both the url to  direct to if the user accepts and the url to be redirected to if the  user denies. The key for these array elements are <code>next</code> and <code>cancel_url</code>,  respectively. Here’s a quick example:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>$url = $facebook-&gt;getLoginUrl(array(</li>
<li> &#8216;req_perms&#8217; =&gt; &#8216;email&#8217;,</li>
<li> &#8216;next&#8217; =&gt; &#8216;http://localhost.com/thanks.php&#8217;,</li>
<li> &#8216;cancel_url&#8217; =&gt; &#8216;http://localhost.com/sorry.php&#8217;</li>
<li>));</li>
</ol>
</div>
<pre>$url = $facebook-&gt;getLoginUrl(array(
    'req_perms' =&gt; 'email',
    'next' =&gt; 'http://localhost.com/thanks.php',
    'cancel_url' =&gt; 'http://localhost.com/sorry.php'
));</pre>
<p>If not specified, the default is the requesting script’s location.</p>
<div><img src="http://s3.amazonaws.com/nettuts/708_facebook/fb_additional_permissions.png" alt="" width="600" height="478" /></div>
<h3>Checking for Extended Permissions</h3>
<p>Since the user can easily revoke permissions, the application should  always check if a given permission is granted before using it, specially  if it’s about publishing something. We will have to use the legacy API,  as <a href="http://forum.developers.facebook.com/viewtopic.php?id=58565">it  seems it’s not fully implemented with the new one yet</a>.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>$uid = $facebook-&gt;getUser();</li>
<li></li>
<li># users.hasAppPermission</li>
<li>$api_call = array(</li>
<li> &#8216;method&#8217; =&gt; &#8216;users.hasAppPermission&#8217;,</li>
<li> &#8216;uid&#8217; =&gt; $uid,</li>
<li> &#8216;ext_perm&#8217; =&gt; &#8216;publish_stream&#8217;</li>
<li>);</li>
<li>$users_hasapppermission = $facebook-&gt;api($api_call);</li>
<li>print_r($users_hasapppermission);</li>
</ol>
</div>
<pre>    $uid = $facebook-&gt;getUser();

    # users.hasAppPermission
    $api_call = array(
        'method' =&gt; 'users.hasAppPermission',
        'uid' =&gt; $uid,
        'ext_perm' =&gt; 'publish_stream'
    );
    $users_hasapppermission = $facebook-&gt;api($api_call);
    print_r($users_hasapppermission);</pre>
<p>The <code>ext_perm</code> will only support <a href="http://developers.facebook.com/docs/reference/rest/users.hasAppPermission">the  old list of available permissions</a>.</p>
<h3>Publishing to the Wall</h3>
<p>Let’s post something to the wall after verifying the user has the <code>publish_stream</code> permission.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li># let&#8217;s check if the user has granted access to posting in the wall</li>
<li>$api_call = array(</li>
<li> &#8216;method&#8217; =&gt; &#8216;users.hasAppPermission&#8217;,</li>
<li> &#8216;uid&#8217; =&gt; $uid,</li>
<li> &#8216;ext_perm&#8217; =&gt; &#8216;publish_stream&#8217;</li>
<li>);</li>
<li>$can_post = $facebook-&gt;api($api_call);</li>
<li>if($can_post){</li>
<li> # post it!</li>
<li> $facebook-&gt;api(&#8216;/&#8217;.$uid.&#8217;/feed&#8217;, &#8216;post&#8217;, array(&#8216;message&#8217; =&gt; &#8216;Saying hello from my Facebook app!&#8217;));</li>
<li> echo &#8216;Posted!&#8217;;</li>
<li>} else {</li>
<li> die(&#8216;Permissions required!&#8217;);</li>
<li>}</li>
</ol>
</div>
<pre>    # let's check if the user has granted access to posting in the wall
    $api_call = array(
        'method' =&gt; 'users.hasAppPermission',
        'uid' =&gt; $uid,
        'ext_perm' =&gt; 'publish_stream'
    );
    $can_post = $facebook-&gt;api($api_call);
    if($can_post){
        # post it!
        $facebook-&gt;api('/'.$uid.'/feed', 'post', array('message' =&gt; 'Saying hello from my Facebook app!'));
        echo 'Posted!';
    } else {
        die('Permissions required!');
    }</pre>
<p>Essentially, we are making an API call to <code>/&lt;user_id&gt;/feed</code>,  using the POST method (second argument) and an array as a third  argument for the data to be sent. In this case, this third argument  supports <code>message</code>, <code>link</code>, <code>picture</code>, <code>caption</code>,  <code>name</code> and <code>description</code>. Here’s the code:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/#"></a></div>
</div>
<ol>
<li>$facebook-&gt;api(&#8216;/&#8217;.$uid.&#8217;/feed&#8217;, &#8216;post&#8217;, array(</li>
<li> &#8216;message&#8217; =&gt; &#8216;The message&#8217;,</li>
<li> &#8216;name&#8217; =&gt; &#8216;The name&#8217;,</li>
<li> &#8216;description&#8217; =&gt; &#8216;The description&#8217;,</li>
<li> &#8216;caption&#8217; =&gt; &#8216;The caption&#8217;,</li>
<li> &#8216;picture&#8217; =&gt; &#8216;http://i.imgur.com/yx3q2.png&#8217;,</li>
<li> &#8216;link&#8217; =&gt; &#8216;http://net.tutsplus.com/&#8217;</li>
<li>));</li>
</ol>
</div>
<pre>$facebook-&gt;api('/'.$uid.'/feed', 'post', array(
    'message' =&gt; 'The message',
    'name' =&gt; 'The name',
    'description' =&gt; 'The description',
    'caption' =&gt; 'The caption',
    'picture' =&gt; 'http://i.imgur.com/yx3q2.png',
    'link' =&gt; 'http://net.tutsplus.com/'
));</pre>
<p>Here’s how it is posted.</p>
<div><img src="http://s3.amazonaws.com/nettuts/708_facebook/fb_wall.png" alt="" width="600" height="140" /></div>
<h3>Some Additional Information you Should Know:</h3>
<p>The user can easily revoke permissions with two clicks in his or her  wall. You should heavily test what might happen if a user revoked one or  more permissions that are vital for the proper functioning of your  website, or even if the application is fully removed. This is important.</p>
<ul>
<li>In <a href="http://www.facebook.com/editapps.php">Application  Settings</a> you can remove the application entirely by clicking the x  at the right side.</li>
<li>You can remove permissions individually in the <a href="http://www.facebook.com/editapps.php?v=extended">Granted  Additional Permissions</a> section.</li>
</ul>
<hr />
<h2>5. Conclusion</h2>
<p>While Facebook’s authentication capabilities are indeed useful, since  so many people are on Facebook these days, using it as the only method  of authentication in a site is not recommended. What about those who  don’t have Facebook accounts? Are they not allowed to access your  application? Thanks for reading!</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://www.wordpressconnect.net/amazonpress/'>Amazon plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://freelance-php-developer.phpmysql.co.za/2010/06/facebook-connect-user-authentcation/feed/</wfw:commentRss>
		<slash:comments>
