Index: classes/tggr-source-instagram.php
===================================================================
--- classes/tggr-source-instagram.php	(revision 1700719)
+++ classes/tggr-source-instagram.php	(working copy)
@@ -29,7 +29,7 @@
 		 */
 		protected function __construct() {
 			$this->view_folder   = dirname( __DIR__ ) . '/views/'. str_replace( '.php', '', basename( __FILE__ ) );
-			$this->setting_names = array( 'Client ID', 'Highlighted Accounts', 'Banned Accounts', '_newest_media_id' );
+			$this->setting_names = array( 'Client ID', 'Client Secret', 'Redirect URL', 'Access Token', 'Highlighted Accounts', 'Banned Accounts', '_newest_media_id' );
 
 			foreach ( $this->setting_names as $key ) {
 				$this->default_settings[ strtolower( str_replace( ' ', '_', $key ) ) ] = '';
@@ -138,6 +138,7 @@
 		public function import_new_items( $hashtag ) {
 			$media = self::get_new_media(
 				TGGRSettings::get_instance()->settings[ __CLASS__ ]['client_id'],
+				TGGRSettings::get_instance()->settings[ __CLASS__ ]['access_token'],
 				$hashtag,
 				TGGRSettings::get_instance()->settings[ __CLASS__ ]['_newest_media_id']
 			);
@@ -152,21 +153,39 @@
 		 * @mvc Model
 		 *
 		 * @param string $client_id
+		 * @param string $access_token
 		 * @param string $hashtag
 		 * @param string $max_id The ID of the most recent item that is already saved in the database
 		 * @return mixed string|false
 		 */
-		protected static function get_new_media( $client_id, $hashtag, $max_id ) {
+		protected static function get_new_media( $client_id, $access_token, $hashtag, $max_id ) {
 			$response = $media = false;
 
-			if ( $client_id && $hashtag ) {
-				$url = sprintf(
-					'%s/v1/tags/%s/media/recent?client_id=%s',
+			// url for SELF posts https://api.instagram.com/v1/users/self/media/recent/?access_token=XXXX
+			/*
+			 * $url = sprintf(
+					'%s/v1/users/self/media/recent?access_token=%s&count=6',
 					self::API_URL,
+					urlencode( $access_token )
+				);
+			 */
+			// url for PUBLIC tags // https://api.instagram.com/v1/tags/XXXX/media/recent/?access_token=XXXX
+			/*
+			 * $url = sprintf(
+					'%s/v1/tags/%s/media/recent?access_token=%s',
+					self::API_URL,
 					urlencode( str_replace( '#', '', $hashtag ) ),
-					urlencode( $client_id )
+					urlencode( $access_token )
 				);
+			 */
 
+			if ( $access_token && $hashtag ) {
+				$url = sprintf(
+					'%s/v1/users/self/media/recent?access_token=%s&count=6',
+					self::API_URL,
+					urlencode( $access_token )
+				);
+
 				$response = wp_remote_get( $url );
 				$body     = json_decode( wp_remote_retrieve_body( $response ) );
 
@@ -175,7 +194,7 @@
 				}
 			}
 
-			self::log( __METHOD__, 'Results', compact( 'client_id', 'hashtag', 'max_id', 'response' ) );
+//			self::log( __METHOD__, 'Results', compact( 'access_token', 'hashtag', 'max_id', 'response' ) );
 
 			return $media;
 		}
Index: views/tggr-source-instagram/page-settings-section-header.php
===================================================================
--- views/tggr-source-instagram/page-settings-section-header.php	(revision 1700719)
+++ views/tggr-source-instagram/page-settings-section-header.php	(working copy)
@@ -1 +1,67 @@
-<p>You can obtain the Client ID by logging into <a href="https://www.instagram.com/developer/">Instagram's developer portal</a>, and then registering a new client.</p>
+<p>Instructions:</p>
+<p>1. You can obtain the Client ID &amp; Client Secret by logging into <a href="https://www.instagram.com/developer/">Instagram's developer portal</a>, and then registering a new client. Insert them to the fields bellow and click 'Save Changes'.</p>
+<p></p>
+<p>2. Copy the Redirect URL from the field below and paste it in your <strong>Valid redirect URIs</strong> field in your Instagram API Client Settings.</p>
+<p></p>
+<p>3. <a href="" id="get_access_token">Click here to get your Access Token!</a> - After the Access Token is in the field please press Save Changes.</p>
+<p></p>
+<?php
+$tggroptions = get_option( 'tggr_settings', array() );
+$cid = $tggroptions['TGGRSourceInstagram']['client_id'];
+$cse = $tggroptions['TGGRSourceInstagram']['client_secret'];
+$cre = $tggroptions['TGGRSourceInstagram']['redirect_url'];
+$fat = $tggroptions['TGGRSourceInstagram']['access_token'];
+
+if ( ! empty( $_GET['code'] ) ) {
+	$icode = sanitize_text_field( $_GET['code'] );
+} else {
+	$icode = '';
+}
+
+if ( $icode !== '' && $fat === '' ) {
+
+	$uri = 'https://api.instagram.com/oauth/access_token';
+	$data = [
+		'client_id' => $cid,
+		'client_secret' => $cse,
+		'grant_type' => 'authorization_code',
+		'redirect_uri' => $cre,
+		'code' => $icode,
+	];
+
+	$ch = curl_init();
+
+	curl_setopt( $ch, CURLOPT_URL, $uri ); // uri
+	curl_setopt( $ch, CURLOPT_POST, true ); // POST
+	curl_setopt( $ch, CURLOPT_POSTFIELDS, $data ); // POST DATA
+	curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // RETURN RESULT true
+	curl_setopt( $ch, CURLOPT_HEADER, 0 ); // RETURN HEADER false
+	curl_setopt( $ch, CURLOPT_NOBODY, 0 ); // NO RETURN BODY false / we need the body to return
+	curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); // VERIFY SSL HOST false
+	curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); // VERIFY SSL PEER false
+
+	$result = json_decode( curl_exec( $ch ), true ); // execute curl
+
+	$at = $result['access_token'];
+
+	if ( $at !== '' ) {
+		?>
+		<script>
+			(function( $ ) {
+				$( document ).ready( function() {
+					$( '#tggr_instagram_access_token' ).val( '<?php echo $at; ?>' );
+				});
+			})( jQuery );
+		</script>
+		<?php
+	}
+}
+?>
+<script>
+(function( $ ) {
+	$( document ).ready( function() {
+		$( '#tggr_instagram_redirect_url' ).val(window.location.href);
+		$( '#get_access_token' ).attr('href', 'https://www.instagram.com/oauth/authorize/?client_id=' + $('#tggr_instagram_client_id').val() + '&redirect_uri=' + $( '#tggr_instagram_redirect_url' ).val() + '&response_type=code');
+	});
+})( jQuery );
+</script>
\ No newline at end of file
