php - Graph API Get all photos -


i have website people can upload pictures rated/liked etc. developing function if don't want upload pictures can import them there facebook account.

i can login/logout user facebook using php graph api not sure on request need logged in persons photos. have setup login url user_photos permissions.

i had feature few years ago use fql query images using new facebook v4 graph api.

any appreciated.

facebooksession::setdefaultapplication( 'id', 'secret' ); $helper = new     facebookredirectloginhelper('url'); $permissions = array( 'user_photos' ); try { if ( isset( $_session['access_token'] ) ) {     // check if access token has been set.     $session = new facebooksession( $_session['access_token'] ); } else {     // access token code parameter in url.     $session = $helper->getsessionfromredirect(); } } catch( facebookrequestexception $ex ) {  // when facebook returns error. print_r( $ex ); } catch( \exception $ex ) {  // when validation fails or other local issues. print_r( $ex ); } if ( isset( $session ) ) {  // retrieve & store access token in session. $_session['access_token'] = $session->gettoken(); // logged in echo 'successfully logged in!'; } else {  // generate login url facebook authentication. $loginurl = $helper->getloginurl($permissions); echo '<a href="' . $loginurl . '">login</a>'; } 

after user has made login can photos so:

facebooksession::setdefaultapplication($app_id, $app_secret);    $session = new facebooksession($access_token);  $response = (new facebookrequest($session, 'get', '/me/photos?fields=source&limit=100'))->execute(); $object = $response->getgraphobject(); $arr = self::converttoassoc($object); 

put in limit param value.

here how convert facebook-object:

public static function converttoassoc($graphobject){         $arr = $graphobject->asarray();         if ( !array_key_exists('data', $arr) ){             $arr['data'] = '';         }         $arr_data = $arr['data'];          $data = [];         foreach($arr_data $item){             $data[] = get_object_vars($item);            }          return $data;         } 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -