Changeset 81312 in spip-zone


Ignore:
Timestamp:
Mar 12, 2014, 5:32:48 PM (5 years ago)
Author:
cedric@…
Message:

Reparer oembed Twitter : on ne peut plus utiliser l'API v1 anonyme de Twitter, on se rabat donc sur l'API oembed de Twitter, mais on supprime les scripts mouchards qu'ils injectent dans le HTML pour ne garder que le texte
Au passage on continue a supporter les vieilles URLS /#!/ ce que ne fait pas l'oembed natif twitter

Location:
_plugins_/oeproxy
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/oeproxy/oeproxy/twitter.php

    r54619 r81312  
    3838        // and let oEmbed handle the response.
    3939        // fetch http://api.twitter.com/1/statuses/show/$tweet.json
    40         $apiurl = 'http://api.twitter.com/1/statuses/show/'.$tweetid.'.json';
     40        //$apiurl = 'http://api.twitter.com/1/statuses/show/'.$tweetid.'.json';
     41        $apiurl = 'https://api.twitter.com/1/statuses/oembed.json?id='.$tweetid;
    4142        if (!$result = recuperer_page_cache($apiurl)){
    4243                spip_log("could not fetch $apiurl",'oep_twitter');
     
    5152        }
    5253
     54
     55        $data->html = trim(preg_replace(",<script\b[^>]*></script>,Uims","",$data->html));
     56
     57
    5358        #var_dump($data);
     59
     60        // obsolete, plus possible
     61        /*
    5462        // Now extract a few variables from the $data object
    5563        #$created_at = date('d M Y g:i a', strtotime( $data->created_at ) );
     
    7987                'name' => $data->user->name
    8088        );
    81 
     89*/
    8290
    8391        $result = array(
     
    96104                // html (required)
    97105                // The HTML required to display the resource. The HTML should have no padding or margins. Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities. The markup should be valid XHTML 1.0 Basic.
    98                 'html' => trim(recuperer_fond('modeles/oeproxy/twitter',$contexte)),
     106                'html' => $data->html,
    99107
    100108                // width (required)
     
    108116                // author_name (optional)
    109117                // The name of the author/owner of the resource.
    110                 'author_name' => $data->user->name,
     118                'author_name' => $data->author_name,
    111119
    112120                // author_url (optional)
    113121                // A URL for the author/owner of the resource.
    114122                // NIY
    115                 'author_url' => "http://twitter.com/".$data->user->screen_name,
     123                'author_url' => $data->author_url,
    116124
    117125
  • _plugins_/oeproxy/paquet.xml

    r59537 r81312  
    22        prefix="oeproxy"
    33        categorie="outil"
    4         version="0.8.4"
     4        version="0.8.5"
    55        etat="experimental"
    66        compatibilite="[3.0.0-beta;["
Note: See TracChangeset for help on using the changeset viewer.