dev-master
9999999-devThis will allow to login and upload data on facebook and twitter
MIT
The Requires
by jedelhu
laravel social github
This will allow to login and upload data on facebook and twitter
Facebook and Twitter Libraries, (*1)
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"
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
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.'); } }
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" ) );
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" ), );
This will allow to login and upload data on facebook and twitter
MIT
laravel social github