title: Passing multiple HTTP API URL in PHP
body: <p>Am needing to call two or more <code>HTTP API</code> to <code>GET</code> <code>META</code> from Piwik Analytics. Unfortunately, their method of <code>method=API.getBulkRequest</code> will not work for a PHP call, and only for JSON and XML - both of which do not work in this request. </p>
  
  <p>Is it possible to combine</p>
  
  <pre><code>https://demo.piwik.org/?module=API&amp;method=Actions.get&amp;idSite=7&amp;period=month&amp;date=last3&amp;format=xml&amp;token_auth=anonymous
  </code></pre>
  
  <p>and </p>
  
  <pre><code>https://demo.piwik.org/?module=API&amp;method=VisitsSummary.get&amp;idSite=7&amp;period=month&amp;date=last3&amp;format=xml&amp;token_auth=anonymous
  </code></pre>
  
  <p>Using this method of calling <code>API</code></p>
  
  <pre><code>$url = "https://demo.piwik.org/";
  $url .= "?module=API&amp;method=Actions.get";
  $url .= "&amp;idSite=7&amp;period=month&amp;date=last3";
  $url .= "&amp;format=php&amp;filter_sort_order=desc";
  $url .= "&amp;token_auth=anonymous";
  </code></pre>
  
  <p>so I can <code>GET</code> the data using</p>
  
  <pre><code>foreach ($content as $dates =&gt; $row) {
      $visits = @$row['nb_pageviews'] ?: 0;
      $unique = @$row['nb_uniq_pageviews'] ?: 0;
      $actions = @$row['nb_outlinks'] ?: 0;
      $bounce = @$row['bounce_count'] ?: 0;
      $bounce_rate = @$row['bounce_rate'] ?: 0;
      $time = @$row['avg_time_on_site'] ?: 0;
  </code></pre>
  
  <p>Thank you for your help and Merry Xmas tomorrow</p>
  
  <p>UPDATE OF FULL CODE IN <code>.PHP</code> file</p>
  
  <pre><code>&lt;?php
              $url = "https://demo.piwik.org/";
              $url .= "?module=API&amp;method=Actions.get";
              $url .= "&amp;idSite=7&amp;period=month&amp;date=last3";
              $url .= "&amp;format=php&amp;filter_sort_order=desc";
              $url .= "&amp;token_auth=anonymous";
  
              $fetched = file_get_contents($url);
              $content = unserialize($fetched);
              krsort($content);
  
              // case error
              if (!$content) {
                  print("&lt;tr&gt;&lt;td class='month subscriber subscriber-fixed-alone fixed-cell'&gt;&lt;/td&gt;&lt;td class='stat number text-center'&gt;Error, analytics not available at the moment.&lt;/td&gt;&lt;/tr&gt;");
              }
  
              foreach ($content as $dates =&gt; $row) {
                  $visits = @$row['nb_pageviews'] ?: 0;
                  $unique = @$row['nb_uniq_pageviews'] ?: 0;
                  $actions = @$row['nb_outlinks'] ?: 0;
                  $bounce = @$row['bounce_count'] ?: 0;
                  $bounce_rate = @$row['bounce_rate'] ?: 0;
                  $time = @$row['avg_time_on_site'] ?: 0;
  
                  $date = $dates;
                  $action_percent = get_percentage($visits,$actions);
                  $unique_percent = get_percentage($visits,$unique);
  
                  print("&lt;tr&gt;");
                  print("&lt;td class='month subscriber subscriber-fixed-alone fixed-cell'&gt;" .date('F Y',strtotime($date)). "&lt;/td&gt;");
                  print("&lt;td class='stat number text-center'&gt;$visits&lt;/td&gt;");
                  print("&lt;td class='stat number text-center'&gt;$unique ($unique_percent%)&lt;/td&gt;");
                  print("&lt;td class='stat number text-center'&gt;$actions ($action_percent%)&lt;/td&gt;");
                  print("&lt;td class='stat number text-center'&gt;$bounce ($bounce_rate)&lt;/td&gt;");
                  print("&lt;td class='stat number text-center'&gt;$time&lt;/td&gt;");
                  print("&lt;/tr&gt;");
              }?&gt;
  </code></pre>