Changeset 273 for trunk/DashboardTwitter

Show
Ignore:
Timestamp:
08/24/07 02:30:50 (2 years ago)
Author:
fumiakiy
Message:

Test code to check if request was redirected to static.twitter.com... not tested yet as Twitter was back now.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/DashboardTwitter/plugins/DashboardTwitter/DashboardTwitter.pl

    r271 r273  
    4343    </mt:setvarblock> 
    4444    <div id="recent-panel" class="<mt:unless name="tab" eq="recent">hidden</mt:unless>" mt:tab-content="recent"> 
     45    <mt:if name="data"> 
    4546    <mt:loop name="data"> 
    4647        <ul> 
     
    4849        </ul> 
    4950    </mt:loop> 
     51    <mt:else> 
     52    <mt:if name="error"><mt:var name="error"></mt:if> 
     53    </mt:if> 
    5054    </div> 
    5155    <div id="twit-panel" class="<mt:unless name="tab" eq="twit">hidden</mt:unless>" mt:tab-content="twit"> 
     
    123127    my $res = $ua->request($req); 
    124128    return unless $res->is_success(); 
     129    if ( my $prev = $res->previous) { 
     130        if ( ('302' eq $prev->code ) && ( $prev->location =~ m|http://static\.twitter\.com| ) ) { 
     131            $param->{error} = 'Twitter must be in maintenance'; 
     132        } 
     133        else { 
     134            $param->{error} = 'hmm?'; 
     135        } 
     136    } else { 
     137        my $s = $res->content; 
     138        $s =~ s/\\u([0-9a-fA-F]+)/&#x$1;/g; 
     139        eval { 
     140            my $recent = JSON::jsonToObj($s); 
     141            $param->{data} = $recent; 
     142        }; 
     143        if ($@) { 
     144            die $@ ; 
     145        } 
     146    } 
    125147 
    126     my $s = $res->content; 
    127     $s =~ s/\\u([0-9a-fA-F]+)/&#x$1;/g; 
    128     eval { 
    129         my $recent = JSON::jsonToObj($s); 
    130         $param->{data} = $recent; 
    131     }; 
    132     if ($@) { 
    133         die $@ ; 
    134     } 
    135      
    136148    1; 
    137149}