Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Social Logins in PHP with HybridAuth
Apr 16, 2015 @ 16:54:14

The SitePoint PHP blog has posted a new tutorial showing you how to integrate the HybridAuth library into your application for easy logins via popular social sites like Facebook, Twitter or even Google+.

A trend in many of today’s websites is a feature that allows users to sign in via their social network accounts. A classic example is the SitePoint community where users have the option to use their Facebook, Twitter, Google, Yahoo or GitHub account to log in without having to register an account. In this tutorial, we will be learning about HybridAuth – a PHP library that takes the pain out of building a social login feature. HybridAuth acts as an abstract API between your application and the various social APIs and identity providers.

They jump right into things, showing you how to install the library via Composer and configure it to work with a simple Slim-based application. They set up providers for Facebook, Twitter and Google+ and show how to call the "authenticate" method to make the connection. He then starts on the sample application, creating a login page and a database table for user tracking. The process continues showing how to connect the user from the social site to your setup and retrieve their profile information. All the code you'll need is here, including the Slim structure, the database connection setup and the needed templates. You can also find the finished product in this GitHub repository.

tagged: social login tutorial hybridauth facebook twitter googleplus socialnetwork

Link: http://www.sitepoint.com/social-logins-php-hybridauth/

NetTuts.com:
Design Patterns: The Adapter Pattern
Nov 03, 2014 @ 17:54:20

In the latest post in their series looking at common programming design patterns, NetTuts.com talks about the Adapter pattern. This pattern makes it easier to swap out different connection types via an abstracted interface.

In this article, we will continue our discussion on design patterns by taking a look at the adapter design pattern. This particular pattern can be used when your code is dependent on some external API, or any other class that is prone to change frequently. This pattern falls under the category of "structural patterns" because it teaches us how our code and our classes should be structured in order to manage and/or extend them easily.

He starts off with the problem he's aiming to solve: a change in a "Twitter" class from one method name to another. An "adapter" lets an existing class be used from another interface, requiring no to minimal changes to the original class. He refactors the example to use an example of an adapter, creating a class that defines an object that passes in the original "Twitter" class instance and wraps the "send" call in its own method. With this in place, he also shows how to create a brand new adapter for Facebook, mimicking the "send" method, just with different functionality.

tagged: designpattern adapter pattern socialnetwork twitter facebook wrapper tutorial

Link: http://code.tutsplus.com/tutorials/design-patterns-the-adapter-pattern--cms-22262


Trending Topics: