'Not allowed'),403); if(!isset($_REQUEST['nonce']) || !is_string($_REQUEST['nonce']))wp_send_json_error(array('message'=>'Invalid security token.'),403); check_ajax_referer('ai4ranks_integrations','nonce'); $token=get_option('seoai_site_token','');if(!$token)wp_send_json_error(array('message'=>'Connect this website first.'),401); $operation=isset($_POST['operation']) && is_string($_POST['operation']) ? sanitize_key(wp_unslash($_POST['operation'])) : 'status'; if(!in_array($operation,array('status','save_ai','test_ai'),true))wp_send_json_error(array('message'=>'Unsupported action'),400); $body=array('site_token'=>$token,'operation'=>$operation); if($operation==='save_ai') { $body['configuration']=array( 'mode'=>isset($_POST['mode']) && is_string($_POST['mode']) ? sanitize_key(wp_unslash($_POST['mode'])) : '', 'provider'=>isset($_POST['provider']) && is_string($_POST['provider']) ? sanitize_key(wp_unslash($_POST['provider'])) : '', 'model'=>isset($_POST['model']) && is_string($_POST['model']) ? sanitize_text_field(wp_unslash($_POST['model'])) : '', ); if(isset($_POST['api_key']) && !is_string($_POST['api_key']))wp_send_json_error(array('message'=>'Invalid API key.'),400); $key=isset($_POST['api_key']) ? sanitize_text_field(wp_unslash($_POST['api_key'])) : ''; if(strlen($key)>4096 || ($key!=='' && !preg_match('/\\A[\\x21-\\x7e]+\\z/D',$key)))wp_send_json_error(array('message'=>'Invalid API key.'),400); if($key!=='') { $host=wp_parse_url(SEOAI_PLATFORM_URL,PHP_URL_HOST); if(wp_parse_url(SEOAI_PLATFORM_URL,PHP_URL_SCHEME)!=='https' && !in_array($host,array('localhost','127.0.0.1','::1'),true))wp_send_json_error(array('message'=>'HTTPS is required to save an API key.'),400); $body['configuration']['api_key']=$key; } } $response=wp_remote_post(SEOAI_PLATFORM_URL.'/api/plugin/integrations',array('headers'=>array('Content-Type'=>'application/json'),'body'=>wp_json_encode($body),'timeout'=>30,'sslverify'=>true)); unset($key,$body); if(is_wp_error($response))wp_send_json_error(array('message'=>'Could not reach AI4Ranks. Try again.'),502); $data=json_decode(wp_remote_retrieve_body($response),true); if(wp_remote_retrieve_response_code($response)!==200 || !is_array($data))wp_send_json_error(array('message'=>isset($data['detail']) && is_string($data['detail']) ? $data['detail'] : 'Could not update connections. Try again.'),400); wp_send_json_success($data); } public static function render() { if(!current_user_can('manage_options'))return; wp_enqueue_script('ai4ranks-integrations',plugins_url('../assets/integrations.js',__FILE__),array(),(string)filemtime(__DIR__.'/../assets/integrations.js'),true); ?>

Integrations & AI

Your website connections and AI preferences in one place.

Loading connections…

Google Business Profile

Coming soon

This optional integration is not available yet.

AI connection

Loading

AI preferences apply to text requests across your AI4Ranks account. Image generation and AI support keep their platform settings.

AI connection preferences

API keys are sent to AI4Ranks when you save, stored encrypted for your account and reused for future requests. They are not saved in WordPress or displayed again. There is no automatic fallback from your API key to AI4Ranks AI.