Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GRKG_ajax() {
- global $wpdb; // this is how you get access to the database
- if(isset($_POST['getAjaxWPTerm'])) {
- $term = urlencode($_POST['getAjaxWPTerm']);
- $getLimit = $_POST['getAjaxWPMax'];
- $getLocale = $_POST['getAjaxWPLocale'];
- $getLocale = str_replace("_", "-", $getLocale);
- $get_useragent = $_SERVER['HTTP_USER_AGENT'];
- $url = 'https://api.bing.com/osjson.aspx?query='.$term.'&setmkt='.$getLocale;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
- curl_setopt($ch, CURLOPT_USERAGENT, $get_useragent);
- curl_setopt($ch, CURLOPT_REFERER, "https://google.com");
- $result = curl_exec($ch);
- curl_close($ch);
- $resultInArray = json_decode($result, true);
- //
- $resultCount = count($resultInArray[1]);
- for ( $i = 1; $i < $resultCount; $i++ ) {
- echo $resultInArray[1][$i].', ';
- if ( $i == $getLimit)
- break;
- }
- }
- wp_die();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement