Changeset 43189 in spip-zone for _plugins_/booksearch


Ignore:
Timestamp:
Dec 28, 2010, 10:43:18 AM (10 years ago)
Author:
fil@…
Message:

gestion d'erreur cf http://core.spip.org/trac/spip/changeset/16855

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/booksearch/inc/booksearch_to_array.php

    r43183 r43189  
    2020function inc_booksearch_to_array($u) {
    2121
     22  try {
     23
    2224    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'FR');
    2325
     
    2628
    2729    $response = $amazonEcs
    28         ->responseGroup('Large')
    29         ->category('Books')
    30         ->search($u);
     30      ->responseGroup('Large')
     31      ->category('Books')
     32      ->search($u);
    3133
    32         // on se limite a la premiere page de resultats
    33     $u = $response['Items']['Item'];
     34    // on se limite a la premiere page de resultats
     35    $u = @$response['Items']['Item'];
    3436
    35         // simplifier le tableau des resultats, on se fiche des liens amazon
     37    // simplifier le tableau des resultats, on se fiche des liens amazon
     38    if (is_array($u))
    3639    foreach($u as $k => &$v) {
    37         #unset($u[$k]['DetailPageURL']);
    38         #unset($u[$k]['ItemLinks']);
    39         foreach ($u[$k]['ItemAttributes'] as $k2 => $v2)
    40                 $u[$k][$k2] = $v2;
    41         unset($u[$k]['ItemAttributes']);
     40      #unset($u[$k]['DetailPageURL']);
     41      #unset($u[$k]['ItemLinks']);
     42      foreach ($u[$k]['ItemAttributes'] as $k2 => $v2)
     43        $u[$k][$k2] = $v2;
     44      unset($u[$k]['ItemAttributes']);
    4245    }
     46    # cas a 0 reponse
     47    else
     48      $u = array();
     49  } catch (Exception $e) {
     50    return $e;
     51  }
    4352
    44         return $u;
     53  return $u;
    4554
    4655}
Note: See TracChangeset for help on using the changeset viewer.