function registerSessionUsage($mv_session_hash, $domain, $shared_key, &$mv_session_id, &$error_message, $serviceUrl = "", $ignoreSSLWarnings = false, $cookies = null) { // Connect to MV-ID's session security service to register a valid application session $client = new JsonWspClient(trim($serviceUrl) != "" ? $serviceUrl : "https://signon.mv-nordic.com/session-security/SessionSecurity/jsonwsp/description", $ignoreSSLWarnings, $cookies); $client->setViaProxy(true); // Send registration request $response = $client->CallMethod("registerSessionUsage", array("mv_session_hash" => $mv_session_hash, "domain" => $domain)); if ($response->getJsonWspType() == JsonWspType::Response && $response->getCallResult() == JsonWspCallResult::Success) { // Get recieve a server-to-server nonse in order to respond to MV-ID's challenge $responseJson = $response->getJsonResponse(); $result = $responseJson["result"]; if ($result["method_result"]["res_code"] != 0) { $error_message = $result["method_result"]["res_msg"]; return false; } $nonce = $result["nonce"]; // Build mv_session_id and store it as a cookie $mv_session_id = md5($mv_session_hash . $nonce . $shared_key); return true; } else { if ($response->getJsonWspType() == JsonWspType::Fault) { // Handle service fault here $error_message = "Service fault: " . $response->getServiceFault()->getString(); return false; } } }
******************************************************************************/ /****************************************************************************** JSONWSP PHP Client library example This example demonstrates the simple nature of the jsonwsp client. In the example a client object is created with a valid jsonwsp service description url. The setViaProxy is used to force the client to use the description url host to call service methods. Then a method call is made and the result is checked and parsed. ******************************************************************************/ // Include the client classes include "../jsonwspclient.php"; // Create a new client object $client = new JsonWspClient("http://ladonize.org/python-demos/AlbumService/jsonwsp/description", false, array("CookieName" => "CookieValue")); // Use a proxy instead of the native service url (from the description) $client->setViaProxy(true); // Call a service method by name and with an associative array as arguments $response = $client->CallMethod("listBands", array("search_frase" => "Swan")); // Check responsetype and callresult for a valid response if ($response->getJsonWspType() == JsonWspType::Response && $response->getCallResult() == JsonWspCallResult::Success) { // Get the result data $responseJson = $response->getJsonResponse(); $result = $responseJson["result"]; // Output succes and the contents of the result echo "Valid response:<br><pre>" . print_r($result, true) . "</pre>"; } else { if ($response->getJsonWspType() == JsonWspType::Fault) { // Handle service fault here echo "Service fault: " . $response->getServiceFault()->getString();