0

Until now I'm calling a web service with using specific function like hook_user_logout, _validate, _submit..., but now I need to create a page that will display details that I'll receive results from the web service, but I don't know how to call when I enter lets say user/%/reports.

Also on that page there will be a link that will display more details that will come from the webservice.

Is there a function for page load, url open or something similar in Drupal 7?

Here's my part of the code when a user logouts.

<?php

function mymodyle_user_logout($account) {

    global $user;

    $username = $user -> name;
    $ip_address = $_SERVER["REMOTE_ADDR"];
    $session_id = session_id();

    $xml_string = '<some_method>
       <username>' . $username . '</username>
       <ip_address>' . $ip_address . '</ip_address>
       <session_id>' . $session_id . '</session_id>
       <language>en</language>
       </some_method>';

    $client = new nusoap_client('http://10.10.60.80:8090/CardHolderAuthentication.asmx?wsdl',  array('soap_version' => SOAP_1_1, 'trace' => 1, 'exeptions' => true));
    $client -> soap_defencoding = 'UTF-8';
    $client -> decode_utf8 = FALSE;

    $result = $client -> call('Logout', array('_xml' => $xml_string));

    //$response = simplexml_load_string($result['LogoutResult']);

    //$status = $response -> error->descr_bg;

}
0

If the page content needs to be fetched via an API request, you can use

hook_menu

to define a URL path to function callback to generate the page content.

Basically your own path to the content.

The page callback will fetch the API response from cache or perform the request, cache the response and display it.

  • What if the page is already created with Views? let's say user/%/edit? – user2519032 Jan 30 '14 at 9:47
  • Then you can add a custom block to that page and return the content within that block instead, more info on the Block API – David Thomas Jan 30 '14 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.