WordPress.org

Plugin Directory

Changeset 626363


Ignore:
Timestamp:
11/17/12 03:57:17 (17 months ago)
Author:
dllh
Message:

Tumblr Importer: Make drafts work. Also remove some debug output that's no longer really needed, and replace a member reference with a call to a function that returns it that's used in a filter elsewhere.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tumblr-importer/branches/newapi/tumblr-importer.php

    r626348 r626363  
    6464        $this->consumerkey = defined ('TUMBLR_CONSUMER_KEY') ? TUMBLR_CONSUMER_KEY : ( !empty($_POST['consumerkey']) ? $_POST['consumerkey'] : $this->consumerkey ); 
    6565        $this->secretkey = defined ('TUMBLR_SECRET_KEY') ? TUMBLR_SECRET_KEY : ( !empty($_POST['secretkey']) ? $_POST['secretkey'] : $this->secretkey ); 
    66          
    67         var_dump($this); 
    6866         
    6967        // if we have access tokens, verify that they work 
     
    340338         
    341339        $this->error=null; 
    342          
    343340        if ( !empty( $this->blog[$url]['progress'] ) ) { 
    344341            $done = false; 
     
    457454        else $count = TUMBLR_MAX_IMPORT; 
    458455 
     456        add_filter( 'tumblr_post_type', function() { return 'draft'; } ); 
    459457        $imported_posts = $this->fetch_posts($url, $start, $count, $this->email, $this->password, 'draft' ); 
    460458 
     
    749747        $post_type = apply_filters( 'tumblr_post_type', '' ); 
    750748        $url = trailingslashit( "http://api.tumblr.com/v2/blog/$url/posts/$post_type" ); 
    751  
     749         
    752750        do_action( 'tumblr_importer_pre_fetch_posts' ); 
    753751 
    754         $params = array( 
    755             'offset'=>$start, 
    756             'limit'=>$count, 
    757             'api_key' => apply_filters( 'tumblr_importer_get_consumer_key', '' ), 
    758         ); 
    759  
    760         if ( !empty($state) ) $params['state'] = $state; 
    761         $url = add_query_arg( $params, $url ); 
     752        // These extra params hose up the auth if passed for oauth requests e.g. for drafts, so use them only for normal posts. 
     753        if ( '' == $post_type ) { 
     754            $params = array( 
     755                'offset'  => $start, 
     756                'limit'   => $count, 
     757                'api_key' => apply_filters( 'tumblr_importer_get_consumer_key', '' ), 
     758            ); 
     759            $url = add_query_arg( $params, $url ); 
     760        } 
    762761 
    763762        $response = $this->oauth_get_request($url); 
     
    980979            return false; 
    981980     
    982         $params = array('oauth_consumer_key' => $this->consumerkey, 
     981        $params = array('oauth_consumer_key' => $this->get_consumer_key(), 
    983982                "oauth_nonce" => time(), 
    984983                "oauth_timestamp" => time(), 
Note: See TracChangeset for help on using the changeset viewer.