You are here

public function InstapageCmsPluginAPIModel::enterpriseCall in Instapage plugin 8.3

Same name and namespace in other branches
  1. 7.3 core/models/InstapageCmsPluginAPIModel.php \InstapageCmsPluginAPIModel::enterpriseCall()

Performs the request to Instapage pageserver.

Parameters

string $url URL of the request.:

string $host Host of the request. It will be used for request header.:

array $cookies Cookie array.:

Return value

object $response Request response.

File

core/models/InstapageCmsPluginAPIModel.php, line 44

Class

InstapageCmsPluginAPIModel
Class responsible for communication with Instapage app via API.

Code

public function enterpriseCall($url, $host = '', $cookies = false) {
  $data = array();
  $headers = array();
  $host = $host ? $host : $_SERVER['HTTP_HOST'];
  $integration = InstapageCmsPluginConnector::getSelectedConnector()->name;
  $data['integration'] = $integration;
  $data['useragent'] = $_SERVER['HTTP_USER_AGENT'];
  $data['ip'] = $_SERVER['REMOTE_ADDR'];
  $data['cookies'] = $cookies;
  $data['custom'] = filter_input(INPUT_GET, 'custom');
  $data['variant'] = filter_input(INPUT_GET, 'variant');
  $data['requestHost'] = $host;
  $headers['integration'] = $integration;
  $headers['host'] = $host;
  $response = InstapageCmsPluginConnector::getSelectedConnector()
    ->remoteRequest($url, $data, $headers, 'POST');
  InstapageCmsPluginHelper::writeDiagnostics($url, 'Enterprise call URL');
  InstapageCmsPluginHelper::writeDiagnostics($host, 'Enterprise call host');
  InstapageCmsPluginHelper::writeDiagnostics($headers, 'Enterprise call headers');
  InstapageCmsPluginHelper::writeDiagnostics($data, 'Enterprise call data');
  InstapageCmsPluginHelper::writeDiagnostics($response, 'Enterprise call response');
  return $response;
}