Changeset 621437
- Timestamp:
- 11/05/2012 09:37:50 PM (13 years ago)
- Location:
- kickpress/trunk
- Files:
-
- 2 edited
-
kickpress-api.php (modified) (9 diffs)
-
kickpress-oauth.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kickpress/trunk/kickpress-api.php
r619608 r621437 1752 1752 ) ); 1753 1753 1754 $uri = implode( '/', array( 1755 get_bloginfo( 'url' ), 1756 kickpress_get_api_trigger(), 1757 sprintf( "%s[%s]/", 1758 $this->params['action'], 1759 $this->params['action_key'] 1760 ) 1761 ) ); 1762 1754 1763 $query = 'POST' == $method ? $_POST : $_GET; 1755 1764 … … 2713 2722 $post_type = $this->params['post_type']; 2714 2723 2715 if ( 'xml' == $format ) { 2716 $new_comments = $this->import_comments_xml( $_REQUEST['data'] ); 2717 } elseif ( 'debug' == $format ) { 2718 $new_comments = array ( 2719 (object) array( 2720 'id' => '191', 2721 'post_id' => '1340', 2722 'date' => 'Wed, 31 Oct 2012 13:27:19 +0000', 2723 'modified' => 'Wed, 31 Oct 2012 13:27:19 +0000', 2724 'author' => (object) array( 2725 'name' => 'Andrew Scott', 2726 'email' => 'ascott@rbc.org', 2727 'url' => 'http://rubberchickenfarm.com' 2728 ), 2729 'content' => 'Bookmark: Privacy Policy', 2730 'status' => 'deleted' 2731 ) 2732 ); 2733 } else { 2734 $new_comments = $this->import_comments_json( $_REQUEST['data'] ); 2735 } 2724 $func = array( $this, "import_comments_{$format}" ); 2725 $args = $_REQUEST['data']; 2726 2727 if ( is_callable( $func ) ) 2728 $new_comments = call_user_func( $func, $args ); 2729 else return; 2736 2730 2737 2731 $comments = array(); … … 2741 2735 $comment->modified = $comment->date; 2742 2736 2743 $comments[$comment->id]['new'] =& $comment; 2737 if ( 0 < $comment->id ) 2738 $comments[$comment->id]['new'] =& $comment; 2739 else 2740 $comments['new'][] =& $comment; 2744 2741 } 2745 2742 … … 2755 2752 2756 2753 unset( $comment ); 2757 } 2758 2759 foreach ( $comments as $comment_id => $comment ) { 2760 if ( ! isset( $comment['new'] ) ) { 2761 // no new comment, skip ahead 2762 continue; 2763 } elseif ( ! isset( $comment['old'] ) ) { 2764 // insert comment 2765 } else { 2766 $old_mod_date = strtotime( $comment['old']->modified ); 2767 $new_mod_date = strtotime( $comment['new']->modified ); 2768 if ( $new_mod_date <= $old_mod_date ) 2769 // keep old comment, skip ahead 2770 continue; 2771 } 2772 2773 if ( 'bookmarks' == $action_key ) { 2774 $this->import_bookmark( $comment['new'] ); 2775 } elseif ( 'notes' == $action_key ) { 2776 $this->import_note( $comment['new'] ); 2754 2755 $type = substr( $action_key, 0, -1 ); 2756 $func = array( $this, "import_{$type}" ); 2757 2758 if ( is_callable( $func ) ) { 2759 foreach ( $comments['new'] as $comment ) { 2760 call_user_func( $func, $comment ); 2761 } 2762 2763 unset( $comments['new'] ); 2764 2765 foreach ( $comments as $comment_id => $comment ) { 2766 if ( ! isset( $comment['new'] ) ) { 2767 // no new comment, skip ahead 2768 continue; 2769 } elseif ( ! isset( $comment['old'] ) ) { 2770 // no old comment, continue 2771 } else { 2772 $old_mod_date = strtotime( $comment['old']->modified ); 2773 $new_mod_date = strtotime( $comment['new']->modified ); 2774 if ( $new_mod_date <= $old_mod_date ) 2775 // keep old comment, skip ahead 2776 continue; 2777 } 2778 2779 call_user_func( $func, $comment['new'] ); 2780 } 2777 2781 } 2778 2782 } … … 2792 2796 foreach ( $sxe->comment as $node ) { 2793 2797 $comments[] = (object) array( 2794 'id' => (string) $node['id'], 2795 'post_id' => (string) $node['post_id'], 2796 'date' => (string) $node->date, 2797 'modified' => (string) $node->modified, 2798 'author' => (object) array( 2798 'id' => (string) $node['id'], 2799 'mobile_id' => (string) $node['mobile_id'], 2800 'post_id' => (string) $node['post_id'], 2801 'date' => (string) $node->date, 2802 'modified' => (string) $node->modified, 2803 'author' => (object) array( 2799 2804 'name' => (string) $node->author->name, 2800 2805 'email' => (string) $node->author->email, 2801 2806 'url' => (string) $node->author->url 2802 2807 ), 2803 'title' => trim( (string) $node->title ),2804 'content' => trim( (string) $node->content ),2805 'status' => (string) $node->status2808 'title' => trim( (string) $node->title ), 2809 'content' => trim( (string) $node->content ), 2810 'status' => (string) $node->status 2806 2811 ); 2807 2812 } 2808 2813 2809 2814 return $comments; 2815 } 2816 2817 private function import_comments_debug( $text ) { 2818 return array ( 2819 (object) array( 2820 'id' => '191', 2821 'mobile_id' => '17', 2822 'post_id' => '1340', 2823 'date' => 'Wed, 31 Oct 2012 13:27:19 +0000', 2824 'modified' => 'Wed, 31 Oct 2012 13:27:19 +0000', 2825 'author' => (object) array( 2826 'name' => 'Andrew Scott', 2827 'email' => 'ascott@rbc.org', 2828 'url' => 'http://rubberchickenfarm.com' 2829 ), 2830 'content' => 'Bookmark: Privacy Policy', 2831 'status' => 'trash' 2832 ) 2833 ); 2810 2834 } 2811 2835 … … 2813 2837 if ( 'trash' == $bookmark->status ) { 2814 2838 kickpress_delete_bookmark( $bookmark->post_id ); 2839 2840 // populate action result 2815 2841 } else { 2816 2842 kickpress_insert_bookmark( $bookmark->post_id ); 2843 2844 // populate action result 2817 2845 } 2818 2846 } … … 2823 2851 if ( 'trash' == $note->status ) { 2824 2852 kickpress_delete_note( $note->id ); 2853 2854 // populate action result 2825 2855 } elseif ( 0 == $note->id ) { 2826 2856 $time = strtotime( $note->date ) + $offset; … … 2834 2864 'comment_type' => 'note' 2835 2865 ) ); 2866 2867 // populate action result 2836 2868 } else { 2837 2869 $time = strtotime( $note->modified ) + $offset; … … 2845 2877 'comment_type' => 'note' 2846 2878 ) ); 2879 2880 // populate action result 2847 2881 } 2848 2882 } -
kickpress/trunk/kickpress-oauth.php
r619608 r621437 530 530 } 531 531 532 $auth = @trim( $_SERVER['HTTP_AUTHORIZATION']);532 $auth = @trim( stripslashes( $_SERVER['HTTP_AUTHORIZATION'] ) ); 533 533 534 534 if ( stripos( $auth, 'OAuth' ) === 0 ) { … … 611 611 } 612 612 } 613 613 614 614 if ( ! empty( $token ) && ! empty( $token_secret ) ) { 615 615 $provider->set_token( $token, $token_secret ); 616 616 $consumer->set_token( $token, $token_secret ); 617 617 } else { 618 return new WP_Error( 'invalid_request',619 'Failed to validate oauth token' ); 618 /* return new WP_Error( 'invalid_request', 619 'Failed to validate oauth token' ); */ 620 620 } 621 621 } … … 699 699 ) ); 700 700 701 // var_dump( $oauth_signature, $proof_signature );702 703 701 return $oauth_signature == $proof_signature; 704 702 }
Note: See TracChangeset
for help on using the changeset viewer.