Ticket #3003: 3003.diff
File 3003.diff, 8.7 KB (added by , 8 years ago) |
---|
-
classes/tggr-source-flickr.php
diff --git a/classes/tggr-source-flickr.php b/classes/tggr-source-flickr.php index 4847d62..45033af 100755
a b if ( ! class_exists( 'TGGRSourceFlickr' ) ) { 137 137 * @param string $hashtag 138 138 */ 139 139 public function import_new_items( $hashtag ) { 140 if ( empty( TGGRSettings::get_instance()->settings[ __CLASS__ ]['api_key'] ) ){ 141 return; 142 } 140 143 $media = self::get_new_media( 141 144 TGGRSettings::get_instance()->settings[ __CLASS__ ]['api_key'], 142 145 $hashtag, -
classes/tggr-source-google.php
diff --git a/classes/tggr-source-google.php b/classes/tggr-source-google.php index 883bf75..5308d14 100755
a b if ( ! class_exists( 'TGGRSourceGoogle' ) ) { 135 135 * @param string $hashtag 136 136 */ 137 137 public function import_new_items( $hashtag ) { 138 if ( empty( TGGRSettings::get_instance()->settings[ __CLASS__ ]['api_key'] ) ){ 139 return; 140 } 141 138 142 $activities = self::get_new_activities( 139 143 TGGRSettings::get_instance()->settings[ __CLASS__ ]['api_key'], 140 144 $hashtag … … if ( ! class_exists( 'TGGRSourceGoogle' ) ) { 264 268 'name' => $postmeta['author_name'][0], 265 269 'username' => $postmeta['author_name'][0], 266 270 'image' => $postmeta['author_image_url'][0], 271 'userId' => $postmeta['author_id'][0], 267 272 ); 268 273 269 274 $item['itemMeta'] = array( -
classes/tggr-source-instagram.php
diff --git a/classes/tggr-source-instagram.php b/classes/tggr-source-instagram.php index bdd6097..2da018f 100755
a b if ( ! class_exists( 'TGGRSourceInstagram' ) ) { 29 29 */ 30 30 protected function __construct() { 31 31 $this->view_folder = dirname( __DIR__ ) . '/views/'. str_replace( '.php', '', basename( __FILE__ ) ); 32 $this->setting_names = array( 'Client ID', ' Highlighted Accounts', 'Banned Accounts', '_newest_media_id' );32 $this->setting_names = array( 'Client ID', 'Client Secret', 'Redirect URL', 'Access Token', 'Highlighted Accounts', 'Banned Accounts', '_newest_media_id' ); 33 33 34 34 foreach ( $this->setting_names as $key ) { 35 35 $this->default_settings[ strtolower( str_replace( ' ', '_', $key ) ) ] = ''; … … if ( ! class_exists( 'TGGRSourceInstagram' ) ) { 136 136 * @param string $hashtag 137 137 */ 138 138 public function import_new_items( $hashtag ) { 139 if ( empty( TGGRSettings::get_instance()->settings[ __CLASS__ ]['client_id'] ) 140 || empty( TGGRSettings::get_instance()->settings[ __CLASS__ ]['access_token'] ) ){ 141 return; 142 } 139 143 $media = self::get_new_media( 140 144 TGGRSettings::get_instance()->settings[ __CLASS__ ]['client_id'], 145 TGGRSettings::get_instance()->settings[ __CLASS__ ]['access_token'], 141 146 $hashtag, 142 147 TGGRSettings::get_instance()->settings[ __CLASS__ ]['_newest_media_id'] 143 148 ); … … if ( ! class_exists( 'TGGRSourceInstagram' ) ) { 152 157 * @mvc Model 153 158 * 154 159 * @param string $client_id 160 * @param string $access_token 155 161 * @param string $hashtag 156 162 * @param string $max_id The ID of the most recent item that is already saved in the database 157 163 * @return mixed string|false 158 164 */ 159 protected static function get_new_media( $client_id, $ hashtag, $max_id ) {165 protected static function get_new_media( $client_id, $access_token, $hashtag, $max_id ) { 160 166 $response = $media = false; 161 167 162 if ( $client_id && $hashtag ) { 168 // url for SELF posts https://api.instagram.com/v1/users/self/media/recent/?access_token=XXXX 169 if ( $access_token && $hashtag ) { 163 170 $url = sprintf( 164 '%s/v1/ tags/%s/media/recent?client_id=%s',171 '%s/v1/users/self/media/recent?access_token=%s&count=6', 165 172 self::API_URL, 166 urlencode( str_replace( '#', '', $hashtag ) ), 167 urlencode( $client_id ) 173 urlencode( $access_token ) 168 174 ); 169 175 170 176 $response = wp_remote_get( $url ); -
classes/tggr-source-twitter.php
diff --git a/classes/tggr-source-twitter.php b/classes/tggr-source-twitter.php index 624222c..ca4c8ea 100755
a b if ( ! class_exists( 'TGGRSourceTwitter' ) ) { 217 217 * @param string $hashtag 218 218 */ 219 219 public function import_new_items( $hashtag ) { 220 221 if ( empty( TGGRSettings::get_instance()->settings[ __CLASS__ ]['consumer_key'] ) 222 || empty( TGGRSettings::get_instance()->settings[ __CLASS__ ]['consumer_secret'] ) 223 || empty( TGGRSettings::get_instance()->settings[ __CLASS__ ]['consumer_key'] ) ){ 224 return; 225 } 226 220 227 $tweets = self::get_new_hashtagged_tweets( 221 228 TGGRSettings::get_instance()->settings[ __CLASS__ ]['_bearer_token'], 222 229 $hashtag, -
javascript/components/google/index.jsx
diff --git a/javascript/components/google/index.jsx b/javascript/components/google/index.jsx index 39777ae..73428b4 100755
a b export default React.createClass({ 28 28 29 29 return ( 30 30 <div className={ item.itemMeta.cssClasses }> 31 <a className="tggr-author-profile clearfix" href={ url + author.user name} rel="nofollow">32 31 <a className="tggr-author-profile clearfix" href={ url + author.userId } rel="nofollow"> 32 { author.image && <img src={ author.image } alt="" className="tggr-author-avatar" /> } 33 33 <span className="tggr-author-name">{ author.name }</span> 34 34 <span className="tggr-author-username">@{ author.username }</span> 35 35 </a> -
views/tggr-source-instagram/page-settings-section-header.php
diff --git a/views/tggr-source-instagram/page-settings-section-header.php b/views/tggr-source-instagram/page-settings-section-header.php index 5f753b2..7f34b36 100755
a b 1 <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> 1 <p>Instructions:</p> 2 <p>1. You can obtain the Client ID & 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> 3 <p></p> 4 <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> 5 <p></p> 6 <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> 7 <p></p> 8 <?php 9 $tggroptions = get_option( 'tggr_settings', array() ); 10 $cid = $tggroptions['TGGRSourceInstagram']['client_id']; 11 $cse = $tggroptions['TGGRSourceInstagram']['client_secret']; 12 $cre = $tggroptions['TGGRSourceInstagram']['redirect_url']; 13 $fat = $tggroptions['TGGRSourceInstagram']['access_token']; 14 15 if ( ! empty( $_GET['code'] ) ) { 16 $icode = sanitize_text_field( $_GET['code'] ); 17 } else { 18 $icode = ''; 19 } 20 21 if ( $icode !== '' && $fat === '' ) { 22 23 $uri = 'https://api.instagram.com/oauth/access_token'; 24 $data = [ 25 'client_id' => $cid, 26 'client_secret' => $cse, 27 'grant_type' => 'authorization_code', 28 'redirect_uri' => $cre, 29 'code' => $icode, 30 ]; 31 32 $ch = curl_init(); 33 34 curl_setopt( $ch, CURLOPT_URL, $uri ); // uri 35 curl_setopt( $ch, CURLOPT_POST, true ); // POST 36 curl_setopt( $ch, CURLOPT_POSTFIELDS, $data ); // POST DATA 37 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // RETURN RESULT true 38 curl_setopt( $ch, CURLOPT_HEADER, 0 ); // RETURN HEADER false 39 curl_setopt( $ch, CURLOPT_NOBODY, 0 ); // NO RETURN BODY false / we need the body to return 40 curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); // VERIFY SSL HOST false 41 curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); // VERIFY SSL PEER false 42 43 $result = json_decode( curl_exec( $ch ), true ); // execute curl 44 45 $at = $result['access_token']; 46 47 if ( $at !== '' ) { 48 ?> 49 <script> 50 (function( $ ) { 51 $( document ).ready( function() { 52 $( '#tggr_instagram_access_token' ).val( '<?php echo $at; ?>' ); 53 }); 54 })( jQuery ); 55 </script> 56 <?php 57 } 58 } 59 ?> 60 <script> 61 (function( $ ) { 62 $( document ).ready( function() { 63 var redirect_url = '<?php echo $cre; ?>'; 64 if ( ! redirect_url ){ 65 redirect_url = window.location.href; 66 } 67 $( '#tggr_instagram_redirect_url' ).val(redirect_url); 68 $( '#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'); 69 }); 70 })( jQuery ); 71 </script> 72 No newline at end of file