Which hook do I need to use to pull external content in pages? I want some of my pages to pull content from another application. Someone suggest I should write a module to do that.
As I'm a complete beginner in Drupal I was wondering which hook do I need to implement (a snippet would be greatly appreciated) :


hook_page_alter 
hook_page_delivery_callback_alter
something else ?
hook_page_alter() is used to alter the page returned from another module, and hook_page_delivery_callback_alter() is used to change the page delivery callback for a page output from another module. All the hooks with a name ending with _alter are hooks that alter the output of another module, what another module returns, or the data stored by another module.

The hook you should use is hook_menu() to define a page callback, and drupal_http_request() to get the external content.
The minimal code you should use is similar to the following one.

  function mymodule_menu() {
    $items['abc/def'] = array(
      'page callback' =&gt; 'mymodule_external_content_view',
      'access arguments' =&gt; array('access content'),
    );

    return $items;
  }

function mymodule_external_content_view() {
  $response = drupal_http_request($url);
  if (!isset($response-&gt;error)) {
    $data = $response-&gt;data;

    return array(
      '#markup' =&gt; filter_xss($response-&gt;data, $allowed_tags)
    );
  }
}


Replace abc/def with the path of the page you want to output, $url with the URL of the external application, and $allowed_tags with an array of strings for the tags that you want to allow as output. By default, filter_xss() uses array('a', 'em', 'strong', 'cite', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd').