'Associatebox Widget', 'description' => 'Product Api Widget for Amazon', ); parent::__construct( 'Associatebox_Widget', 'Associatebox Widget', $widget_ops ); } function form($instance) { $instance = wp_parse_args((array) $instance, array( 'title' => '' )); $title = $instance['title']; ?>

"ItemSearch", "Keywords" => $keyword, "SearchIndex" => $searchindex2, "ResponseGroup" => "Medium" ); $response=aws_query($params,ABSPATH,$host,"yes"); //var_dump($response); if (!$response) { echo '
'.__('ERROR','associatebox-for-amazon').'
'; echo '
'.__('Please check your keys for the Amazon Product API.','associatebox-for-amazon').'
'; return; } if ($response[ItemSearchResponse][Items][Request][Errors]) { //FEHLER? echo '
'.$response[ItemSearchResponse][Items][Request][Errors][Error][Code].'
'; echo '
'.$response[ItemSearchResponse][Items][Request][Errors][Error][Message].'
'; } //FEHLER else { $anzahl=count($response[ItemSearchResponse][Items][Item]); $multi3=get_post_meta( $page_id, 'associatebox_multiamount3', true ); if ($anzahl<$multi3) { //MULTI 3 $multi3=$anzahl; } $shuffle=get_post_meta($page_id, "associatebox_shuffle", true); //echo "SHUFFLE" .$shuffle; if ($shuffle=="shuffle") { shuffle($response[ItemSearchResponse][Items][Item]); } for($count = 0; $count < $multi3; $count++) { $item=$response[ItemSearchResponse][Items][Item][$count]; echo '
'; echo '
'.htmlspecialchars($item[ItemAttributes][Title]).'
'; echo '
'; echo '
Cover
'; echo "
"; if ($count<$multi3) { echo '
'; } } } } else if ($art=="browse") { //BROWSE $browseid=get_post_meta($page_id, "associatebox_browsenode", true); $searchindex=get_post_meta($page_id, "associatebox_mysearchindex", true); $params=array( "Operation" => "ItemSearch", "BrowseNode" => $browseid, "SearchIndex" => $searchindex, "ResponseGroup" => "Medium" ); $response=aws_query($params,ABSPATH,$host,"yes"); //var_dump($response); if (!$response) { echo '
'.__('ERROR','associatebox-for-amazon').'
'; echo '
'.__('Please check your keys for the Amazon Product API.','associatebox-for-amazon').'
'; return; } $multi2=get_post_meta( $page_id, 'associatebox_multiamount2', true ); //var_dump($response[ItemSearchResponse][Items][Request][Errors]); if ($response[ItemSearchResponse][Items][Request][Errors]) { //FEHLER? echo '
'.$response[ItemSearchResponse][Items][Request][Errors][Error][Code].'
'; echo '
'.$response[ItemSearchResponse][Items][Request][Errors][Error][Message].'
'; } else { $anzahl=count($response[ItemSearchResponse][Items][Item]); $multi2=get_post_meta( $page_id, 'associatebox_multiamount2', true ); if ($anzahl<$multi2) { //MULTI 2 $multi2=$anzahl; } $shuffle=get_post_meta($page_id, "associatebox_shuffle", true); if ($shuffle=="shuffle") { shuffle($response[ItemSearchResponse][Items][Item]); } for($count = 0; $count < $multi2; $count++) { $item=$response[ItemSearchResponse][Items][Item][$count]; echo '
'; echo '
'.htmlspecialchars($item[ItemAttributes][Title]).'
'; echo '
'; echo '
Cover
'; echo "
"; if ($count<$multi2) { echo '
'; } } } //FEHLER ODER NICHT? ENDE BROWSE } else if ($art=="similarity") { //SIM $asinsim=get_post_meta($page_id, "associatebox_asinsim", true); $params = array( 'Operation' => 'SimilarityLookup', 'ItemId' => $asinsim, 'ResponseGroup' => 'Medium' ); $response=aws_query($params,ABSPATH,$host,"yes"); if (!$response) { echo '
'.__('ERROR','associatebox-for-amazon').'
'; echo '
'.__('Please check your keys for the Amazon Product API.','associatebox-for-amazon').'
'; return; } //var_dump($response[SimilarityLookupResponse]); if ($response[SimilarityLookupResponse][Items][Request][Errors]) { echo '
'.$response[SimilarityLookupResponse][Items][Request][Errors][Error][Code].'
'; echo '
'.$response[SimilarityLookupResponse][Items][Request][Errors][Error][Message].'
'; } else { //ANZAHL $anzahl=count($response[SimilarityLookupResponse][Items][Item]); //echo "ANZAHL ".$anzahl; $multi4=get_post_meta( $page_id, 'associatebox_multiamount4', true ); if ($anzahl<$multi4) { //MULTI 4 $multi4=$anzahl; } $shuffle=get_post_meta($page_id, "associatebox_shuffle", true); if ($shuffle=="shuffle") { shuffle($response[SimilarityLookupResponse][Items][Item]); } for($count = 0; $count < $multi4; $count++) { $item=$response[SimilarityLookupResponse][Items][Item][$count]; echo '
'; echo '
'.htmlspecialchars($item[ItemAttributes][Title]).'
'; echo '
'; echo '
Cover
'; echo "
"; if ($count<$multi4) { echo '
'; } } } //ANZAHL } //SIM elseif ($art=="asin") { //ASINS $asins=get_post_meta( $page_id, 'associatebox_asin', true ); //echo $asins; $asins=explode(",",$asins); $shuffle=get_post_meta($page_id, "associatebox_shuffle", true); //echo $shuffle; if ($shuffle=="shuffle") { shuffle($asins); } //echo $asins; $multi=get_post_meta( $page_id, 'associatebox_multiamount', true ); if ($multi>sizeof($asins)) { $multi=sizeof($asins); } $asins = array_slice($asins, 0, $multi); $asins=implode(",",$asins); $params=array( 'Operation' => 'ItemLookup', 'ItemId' => $asins, 'ResponseGroup' => 'Medium' ); $response=aws_query($params,ABSPATH,$host,"no"); if (!$response) { echo '
'.__('ERROR','associatebox-for-amazon').'
'; echo '
'.__('Please check your keys for the Amazon Product API.','associatebox-for-amazon').'
'; return; } if ($response->Items->Request->Errors->Error) { echo '
'.$response->Items->Request->Errors->Error->Code.'
'; echo '
'.$response->Items->Request->Errors->Error->Message.'
'; } else { $max=count($response->Items->Item); //echo $max."
"; $counter=1; foreach ($response->Items->Item as $item) { //echo $counter; echo '
'.htmlspecialchars($item->ItemAttributes->Title).'
'; echo '
'; echo '
Cover
'; if ($counter<$max) { echo '
'; } $counter++; } } } //ASINS echo $after_widget; } } ?>