Sun Carter Sun Carter - 4 months ago 15
PHP Question

How to add permission params to getLoginUrl() in php sdk 3.1.1

How do i add permission parameters to getLoginUrl() in php sdk 3.1.1?

if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}

Answer

You can build an array of extended permissions and call within getLoginUrl.

Refer to: https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/

if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} else {
    $params = array(
      "scope"        => 'read_stream,publish_stream,publish_actions,offline_access',
      "redirect_uri" => 'Redirect_URL'
    );
    $loginUrl = $facebook->getLoginUrl($params);
}