$value) { if (is_array($value)) { $innerArray = serialiseCookies($value); $array[$key] = new XML_RPC_Value($innerArray, $XML_RPC_Struct); } else { $array[$key] = new XML_RPC_Value($value); } } return $array; } // Create the XML-RPC message $message = new XML_RPC_Message('max.view', array()); // Package the cookies into an array as XML_RPC_Values $cookiesStruct = serialiseCookies($_COOKIE); // Add the parameters to the message $message->addParam(new XML_RPC_Value('zone:5', $XML_RPC_String)); $message->addParam(new XML_RPC_Value('', $XML_RPC_String)); $message->addParam(new XML_RPC_Value('', $XML_RPC_String)); $message->addParam(new XML_RPC_Value('0', $XML_RPC_Boolean)); $message->addParam(new XML_RPC_Value($_SERVER['REMOTE_ADDR'], $XML_RPC_String)); $message->addParam(new XML_RPC_Value($cookiesStruct, $XML_RPC_Struct)); // Send the XML-RPC message to the server $response = $client->send($message, 15, 'http'); // Was a response received? if (!$response) { echo 'Error: No XML-RPC response'; } // Was a response an error? if ($response->faultCode() != 0) { echo 'Error: ' . $response->faultString(); } else { // Ensure the response is an array $value = $response->value(); if ($value->kindOf() != $XML_RPC_Array) { echo 'Error: Unexpected response value'; } // Store any cookies sent in the response $cookies = $value->arraymem(1); if ($cookies->kindOf() == $XML_RPC_Array) { $numCookies = $cookies->arraysize(); // For each cookie... for ($counter = 0; $counter < $numCookies; $counter++) { $cookie = $cookies->arraymem($counter); if (($cookie->kindOf() == $XML_RPC_Array) && ($cookie->arraysize() == 3)) { $cookieName = $cookie->arraymem(0); $cookieValue = $cookie->arraymem(1); $cookieTime = $cookie->arraymem(2); setcookie($cookieName->scalarval(), $cookieValue->scalarval(), $cookieTime->scalarval()); } } } // Store the ad in the ad array $advertisement = $value->arraymem(0); if ($advertisement->kindOf() == $XML_RPC_Struct) { $htmlValue = $advertisement->structmem('html'); $adArray[] = $htmlValue->scalarval(); } // Example display code - remove before use if (isset($adArray)) { foreach ($adArray as $value) { echo $value; } } } ?>