type = $type; if($type == 'ajax'){ add_action( 'wp_ajax_action_appip_do_test', array($this,'appip_do_settings_test_ajax') );// register ajax test }elseif($type ='parent'){ add_action( 'wp_ajax_action_appip_do_test', array($this,'appip_do_settings_test_parent') );// register ajax test } } function appip_do_product_ajax(){ check_ajax_referer( 'appip_ajax_do_product', 'security', true ); if( current_user_can( 'manage_options' ) ){ $test = $this->test_API(); global $wp_scripts; global $wp_styles; if (is_a($wp_scripts, 'WP_Scripts')) $wp_scripts->queue = array(); if (is_a($wp_styles, 'WP_Styles')) $wp_styles->queue = array(); wp_enqueue_style( 'plugin-install' ); wp_enqueue_style( 'wp-admin' ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'common' ); wp_enqueue_script( 'plugin-install' ); add_thickbox(); ?> Test

Add an Amazon Product

Tab1 Tab2
Error: Some Required Data is missing.
'; if( strlen($publickey) != 20 ) $error .= 'Error: Amazon Access Key ID is not the correct length (should be 20 characters, not '.strlen($publickey).').
'; if( strlen($privatekey) != 40 ) $error .= 'Error: Amazon Secret Access Key is not the correct length (should be 40 characters, not '.strlen($privatekey).').
'; if( $publickey == '' && $privatekey == '' ) $error = 'Error: Please SAVE your settings BEFORE testing.
'; if( $error != '' ) return $error; $keyword = array('puppy poster','kitten poster','disney movies','Game of Thrones','kids','funsparks','TV shows on DVD','mickey mouse','donald duck'); shuffle($keyword); $pages = array('1','2','3'); shuffle($pages); $params = array(); $params["AWSAccessKeyId"] = $publickey; $params['AssociateTag'] = APIAP_ASSOC_ID; $params['Condition'] = 'All'; $params['IdType'] = 'ASIN'; $params['IncludeReviewsSummary']= 'False'; $params['ItemPage'] = $pages[0]; $params['Keywords'] = $keyword[0]; $params['Operation'] = 'ItemSearch';//'ItemLookup', $params['ResponseGroup'] = 'Medium'; $params['SearchIndex'] = 'All'; $params["Service"] = "AWSECommerceService"; $params["Timestamp"] = gmdate("Y-m-d\TH:i:s\Z"); $params["Version"] = "2013-08-01";//"2011-08-01"; //"2009-03-31"; $params["TruncateReviewsAt"] = '1'; $canonicalized_query = array(); ksort($params); foreach ($params as $param => $value){ $param = str_replace("%7E", "~", rawurlencode($param)); $value = str_replace("%7E", "~", rawurlencode($value)); $canonicalized_query[] = $param."=".$value; } $canonicalized_query = implode("&", $canonicalized_query); $result = $this->get_Result( $canonicalized_query , true, $keyword[0] ); return $result; } function appip_do_settings_test_debug(){ $test = $this->test_API(); global $wp_scripts,$wp_styles; if (is_a($wp_scripts, 'WP_Scripts')) $wp_scripts->queue = array(); if (is_a($wp_styles, 'WP_Styles')) $wp_styles->queue = array(); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'common' ); ?>

Amazon Product API Settings Test

If you can see products listed below, then the test was successful.

Amazon Product Debug Info

This plugin uses wp_remote_request to make Amazon API calls.

Your host allows SSL requests.

Your host allows HTTP requests.

You cannot use this plugin until either CURL or fopen are installed and working. Contact your host for help.

test_API(); global $wp_scripts; global $wp_styles; if (is_a($wp_scripts, 'WP_Scripts')) { $wp_scripts->queue = array(); } if (is_a($wp_styles, 'WP_Styles')) { $wp_styles->queue = array(); } wp_enqueue_style( 'plugin-install' ); wp_enqueue_style( 'wp-admin' ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'common' ); wp_enqueue_script( 'plugin-install' ); add_thickbox(); ?> Test

Amazon Product API Settings Test

Amazon Product API Settings Test

If you can see products listed below, then the test was successful.

type == 'debug') echo ''.$request; //New Transport (use WordPress Remote Request). $response = wp_remote_request($request); if (!is_wp_error($response)) { $xbody = trim(addslashes($response['body'])); if($xbody =='' || strpos($xbody, 'Error:') !== false ){ if($xbody ==''){ return 'Error: Empty Result.
Something when wrong with the request. If you continue to have this problem, check your API keys for accuracy. If you still have the issue, send your Debug key and site URL to plugins@fischercreativemedia.com for help.
'; }else{ return stripslashes($xbody); } } }elseif(!isset($response['body'])){ return 'Error:
Something when wrong with the request (No Body).
Status:'.$status.'
'.print_r($response, true).'
'; }else{ $status = ''; if (isset($response->status)) { $status = $response->status; } return 'Error:
Something when wrong with the request (other).
Status:'.$status.'
'.print_r($response, true).'
'; } $pxml = appip_get_XML_structure_new( $response['body'], 0 ); if(!is_array($pxml)){ return 'Error:'. $pxml2; }else{ $asins = array(); if((bool)$test === true){ if(isset($pxml['Items']['Item']) && is_array($pxml['Items']['Item']) && !empty($pxml['Items']['Item'])){ $multi = isset($pxml['Items']['Item'][0]) ? true : false; if($multi){ $items = $pxml['Items']['Item']; foreach($items as $k => $v ){ $asins[$v['ASIN']] = $v['ASIN']; } }else{ $items = $pxml['Items']['Item']; $asins[$items['ASIN']] = $items['ASIN']; } } } $resultarr1 = appip_plugin_FormatASINResult($pxml, 0, $asins); $resultarr2 = appip_plugin_FormatASINResult($pxml, 1, $asins); foreach($resultarr1 as $key1 => $result1): $mainAArr = (array)$result1; $otherArr = (array)$resultarr2[$key1]; $resultarr[$key1] = (array)$mainAArr + $otherArr; endforeach; $apippnewwindowhtml = $template = ''; $returnval = '' . __( 'Test Successful', 'amazon-product-in-a-post-plugin' ) . '!
'; $resultarr = has_filter('appip_product_array_processed') ? apply_filters('appip_product_array_processed',$resultarr,$apippnewwindowhtml,$resultarr1,$resultarr2,$template) : $resultarr; $resultarr = !is_array($resultarr) ? (array) $resultarr : $resultarr; $thedivider = ''; $totaldisp = 4; $i = 0; $returnval .= ' '; if($keyword != '') $returnval .= ' '."\n"; $returnval .= ' '."\n"; $returnval .= ' '."\n"; shuffle($resultarr); foreach($resultarr as $key => $result): if($i >= $totaldisp) break; if(isset($result['NoData']) && $result['NoData'] == '1'): $returnval .= $result['Error']; if($extratext != ''): $returnval .= $extratext; endif; else: $returnval .= ' '."\n"; endif; $i++; endforeach; $returnval .= ' '."\n"; $returnval .= '
'."\n"; $returnval .= '
'.awsImageGrabber($result['MediumImage'],'amazon-image') . '
'."\n"; $returnval .= '
'."\n"; return $returnval; } return 'Nothing'; } } new amazonAPPIP_NewRequest();