diff --git a/Instagram/Auth.php b/Instagram/Auth.php
index 9cce45c..27e6428 100644
--- a/Instagram/Auth.php
+++ b/Instagram/Auth.php
@@ -61,17 +61,26 @@ public function __construct( array $config = null, \Instagram\Net\ClientInterfac
* @access public
*/
public function authorize() {
- header(
- sprintf(
- 'Location:https://api.instagram.com/oauth/authorize/?client_id=%s&redirect_uri=%s&response_type=code&scope=%s',
- $this->config['client_id'],
- $this->config['redirect_uri'],
- implode( '+', $this->config['scope'] )
- )
- );
+ header('Location:' . $this->getAuthorizationUrl());
exit;
}
+ /**
+ * getAuthorizationUrl
+ *
+ * Return the URL to request authorization from an Instagram user
+ * @return string
+ */
+ public function getAuthorizationUrl()
+ {
+ return sprintf(
+ 'https://api.instagram.com/oauth/authorize/?client_id=%s&redirect_uri=%s&response_type=code&scope=%s',
+ $this->config['client_id'],
+ $this->config['redirect_uri'],
+ implode( '+', $this->config['scope'] )
+ );
+ }
+
/**
* Get the access token
*
diff --git a/README.md b/README.md
index 55d3078..9eb28b3 100644
--- a/README.md
+++ b/README.md
@@ -37,8 +37,16 @@ All methods that access the API can throw exceptions. If the API request fails f
$auth->authorize();
+- You can also just retrieve the authorisation URL and take care of the redirection yourself via
+
+
+
+ $auth->getAuthorizationUrl();
+
+
- This will redirect the user to the Instagram authorization page. After authorization Instagram will redirect the user to the url in `$auth_config['redirect_uri']` with a code that you will need to obtain an access token
+
$_SESSION['instagram_access_token'] = $auth->getAccessToken( $_GET['code'] );