2017 © Pedro Peláez
 

project socialpack

This will allow to login and upload data on facebook and twitter

image

jedelhu/socialpack

This will allow to login and upload data on facebook and twitter

  • Wednesday, September 28, 2016
  • by jedelhu
  • Repository
  • 2 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Socialpack

Facebook and Twitter Libraries, (*1)

Installation

Begin by installing this package through Composer., (*2)

Add this line in composer.json file under "require":, (*3)

"jedelhu/Socialpack": "dev-master",

Add this line in app.php under 'providers':, (*4)

Jedelhu\Socialpack\SocialpackServiceProvider::class

Run this command in command line:, (*5)

php artisan vendor:publish --provider="Jedelhu\Socialpack\SocialpackServiceProvider"

Configuration

Give valid app_id and app_secret keys for both api in config\socialpack.php, (*6)

Callback function for twitter, (*7)

http://yourdomain.com/callbackTwitter

Callback function for facebook, (*8)

http://yourdomain.com/loginFacebook

Change following code in facebook sdk v4 package(to convert in laravel):

Go to vendor\facebook\php-sdk-v4\src\Facebook\Helpers\FacebookRedirectLoginHelper.php on line 123,, (*9)

I change this script:, (*10)

private function makeUrl($redirectUrl, array $scope, array $params = [], $separator = '&')
{
    $state = $this->pseudoRandomStringGenerator->getPseudoRandomString(static::CSRF_LENGTH);
    $this->persistentDataHandler->set('state', $state);

    return $this->oAuth2Client->getAuthorizationUrl($redirectUrl, $state, $scope, $params, $separator);
}

into (I add Session::put('state', $state);), (*11)

private function makeUrl($redirectUrl, array $scope, array $params = [], $separator = '&')
{
    $state = $this->pseudoRandomStringGenerator->getPseudoRandomString(static::CSRF_LENGTH);
    $this->persistentDataHandler->set('state', $state);
    Session::put('state', $state);
    return $this->oAuth2Client->getAuthorizationUrl($redirectUrl, $state, $scope, $params, $separator);
}

and on line 234, I change this script:, (*12)

protected function validateCsrf()
{
    $state = $this->getState();
    $savedState = $this->persistentDataHandler->get('state');

    if (!$state || !$savedState) {
        throw new FacebookSDKException('Cross-site request forgery validation failed. Required param "state" missing.');
    }

    $savedLen = strlen($savedState);
    $givenLen = strlen($state);

    if ($savedLen !== $givenLen) {
        throw new FacebookSDKException('Cross-site request forgery validation failed. The "state" param from the URL and session do not match.');
    }

    $result = 0;
    for ($i = 0; $i < $savedLen; $i++) {
        $result |= ord($state[$i]) ^ ord($savedState[$i]);
    }

    if ($result !== 0) {
        throw new FacebookSDKException('Cross-site request forgery validation failed. The "state" param from the URL and session do not match.');
    }
}

into (I added $this->persistentDataHandler->set('state', Session::get('state'));), (*13)

protected function validateCsrf()
{
    $state = $this->getState();
    $this->persistentDataHandler->set('state', Session::get('state'));
    $savedState = $this->persistentDataHandler->get('state');

    if (!$state || !$savedState) {
        throw new FacebookSDKException('Cross-site request forgery validation failed. Required param "state" missing.');
    }

    $savedLen = strlen($savedState);
    $givenLen = strlen($state);

    if ($savedLen !== $givenLen) {
        throw new FacebookSDKException('Cross-site request forgery validation failed. The "state" param from the URL and session do not match.');
    }

    $result = 0;
    for ($i = 0; $i < $savedLen; $i++) {
        $result |= ord($state[$i]) ^ ord($savedState[$i]);
    }

    if ($result !== 0) {
        throw new FacebookSDKException('Cross-site request forgery validation failed. The "state" param from the URL and session do not match.');
    }
}

How to use for Twitter Api

Add this call at the top of the controller:, (*14)

use Jedelhu\Socialpack\SocialpackController;

Call function:, (*15)

$result=$social->loginTwitter($data);

To get profile info(Includes profile info and images):, (*16)

        $data=array(
            'profile' => "yes",
            );

To get tweet:, (*17)

        $data=array(
            'recent_tweets' => array(
                "show" => "yes"
            )
            );

To post Tweet:, (*18)

              $data=array(
                   'post_tweet' => array(
                       'show' => "no",
                       'message' => "Test Tweet"
                   )
                   );

How to use for Facebook Api

Add this at the top of the controller:, (*19)

use Jedelhu\Socialpack\SocialpackController;

Call function( get session in loginFacebook() function):, (*20)

 Session::put('data', $data);

$result=$social->loginFacebook();

To get profile info:, (*21)

        $data=array(
            'profile' => "yes",
            );

To get Friends:, (*22)

        $data=array(
            'friends' => "yes",
                  );

To get Profile Image:, (*23)

             $data=array(
                'profile_image' => "yes",
            );

To get published post:, (*24)

             $data=array(
                'published_post' => "yes",
            );

To get like pages:, (*25)

             $data=array(
                'like_pages' => "yes",
            );

To get all photos:, (*26)

             $data=array(
                'all_photos' => "yes",
            );

Post on timeline:, (*27)

             $data=array(
                'post_timeline' => "yes",
                array(
                "show" => "yes",
                "message" => "My post "
                ),
            );

Post Image on timeline:, (*28)

             $data=array(
                'post_timeline' => "yes",
                array(
                "show" => "yes",
                "message" => "My post ",
                "url" => ""
                ),
            );

Add Article on time line:, (*29)

             $data=array(
                  'post_link_timeline' => "yes",
                            array(
                                "show" => "yes",
                                "link" => "http://www.espn.in/football/european-championship/74/blog/post/2889086/euro-2016s-six-best-group-games-belgium-vs-italy-england-vs-wales-and-more"
                            ),
            );

The Versions

28/09 2016

dev-master

9999999-dev

This will allow to login and upload data on facebook and twitter

  Sources   Download

MIT

The Requires

 

by Avatar jedelhu

laravel social github