Week 7: GSoC 17 Creating First Social Post Implementer

Submitted by hudixt on Thu, 07/20/2017 - 16:41

I am working on Adding support for The League OAuth2 and new implementers for social auth and social post under the mentorship of Getulio Sánchez "gvso" (Paraguay) and Daniel Harris “dahacouk” (UK).

Last week, I created the implementers for the Officially supported base client of The League OAuth2 client library. Due to large number of implementers involved and time required to thoroughly review each implementer, my GSoC mentor Getulio Sánchez advised to start working on my first social post implementer using The League OAuth2 library. The first social post implementer I chose to create is Social Post Facebook.

Here are some of the things that I worked on during the 7th week of GSoC coding period.

Defining Social Post Data Handler in Social Post - To efficiently and make code readable SocialPostDataHandler.php was defined to  write and read data from the Session.

Creating the first social_post implementer - The first social_auth implementer I choose to implement is social_auth_facebook. We’ll be using Facebook Provider for OAuth 2.0 Client for authentication purpose and Facebook Graph SDK to make API calls on behalf of the user.

  • Checking The Required library for Social Post implementer: we’ll extend The League OAuth2 client by using Facebook provider and so we need to make sure that the library is installed. We’ll also require Facebook Graph SDK to make API calls to post on behalf of the user.

  • Creating social_post_facebook settings form page:  A new setting form is created to facilitate and configure the Social Post Facebook, it’s similar to Social Auth Facebook except for some fields such as data points, etc which are not required in Social Post implementers.

  • Creating Instance of \League\OAuth2\Client\Provider\Facebook class.

  • Refactoring Social Post Twitter - The social post twitter was earlier created as a part of last year GSoC project, although social post facebook time implementation  is different from social post twitter  but code written before can be used again.

  • Getting an authorization url: Apart from requesting user data we need to explicitly request the permission to post on behalf of the user. This permission is requested via scope ‘publish_actions’.

$authUrl = $provider->getAuthorizationUrl([

          'scope' => ['email', ‘publish_actions’],


  • Getting an access token: $token = $provider->getAccessToken('authorization_code', [

      'code' => $_GET['code']


These were some of the important topics related to my project that I had to work on during my seventh week. My goal for the next week is to complete this Social Post implementer and then work on other Social Auth implementers.