예제 #1
0
 public function testFbInfoFetcherGetsFriendsList()
 {
     $mockedResponseForFriendsListCall = $this->getMockResponseForFriendsListRequest();
     $mockedFbSDK = m::mock('SammyK\\LaravelFacebookSdk\\LaravelFacebookSdk');
     $mockedFbSDK->shouldReceive('get')->with('/me/taggable_friends')->andReturn($mockedResponseForFriendsListCall);
     $mockedFbSDK->shouldReceive('getAccessTokenFromRedirect')->andReturn('token');
     $mockedFbSDK->shouldReceive('setDefaultAccessToken');
     $fetcherInstance = new FbInfoFetcher($mockedFbSDK);
     $friendsArray = $fetcherInstance->getAuthorizedUsersFriendsArray();
     $this->assertEquals(2, count($friendsArray));
     $this->assertInstanceOf('Facebook\\GraphNodes\\GraphNode', $friendsArray[0]);
     $this->assertEquals('Anna Soj', $friendsArray[0]->getProperty('name'));
 }
예제 #2
0
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'WelcomeController@index');
Route::get('home', 'HomeController@index');
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::get('facebook_test', function () {
    return View::make('facebook_test');
});
Route::get('/facebook/login', function (SammyK\LaravelFacebookSdk\LaravelFacebookSdk $fb) {
    // Send an array of permissions to request
    $login_url = $fb->getLoginUrl(['email', 'user_photos', 'user_friends', 'publish_actions']);
    // Obviously you'd do this in blade :)
    echo '<a href="' . $login_url . '">Login with Facebook</a>';
});
Route::get('/facebook/callback', function (SammyK\LaravelFacebookSdk\LaravelFacebookSdk $fb) {
    $fbInfoFetcherInstance = new FbInfoFetcher($fb);
    $accessToken = $fbInfoFetcherInstance->getAccessToken();
    $friendsArray = $fbInfoFetcherInstance->getAuthorizedUsersFriendsArray();
    $firstFriend = $friendsArray[0];
    $friendsName = $firstFriend->getProperty('name');
    $posterInstance = new FbPoster($fb);
    $posterInstance->postMessageWithLinkAndPictureOnAuthorizedUsersFeed('message_tesss', 'http://www.onet.pl/', 'https://maxwelldemon.files.wordpress.com/2012/03/2x1-rectangle.png');
    //$imageInstance = $fbInfoFetcherInstance->getTaggableFriendsPictureById($friendsId);
    //return $imageInstance->response('png');
});