zackchandler (owner)

Revisions

gist: 209590 Download_button fork
public
Public Clone URL: git://gist.github.com/209590.git
Embed All Files: show embed
PHP #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
 
  // Loosely based on the Jason Levitt PHP Proxy example for Yahoo! Web services.
  
  define ('HOSTNAME', 'https://myapp.servicesidekick.com/');
 
  $path = ($_POST['api_path']) ? $_POST['api_path'] : $_GET['api_path'];
 
  // Build url and add any parameters
  $url = HOSTNAME.$path.'?';
  while ($element = current($_GET)) {
$url .= key($_GET).'='.$element.'&';
next($_GET);
}
 
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  curl_setopt($ch, CURLOPT_USERPWD, 'abc123:abc123');
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $HTTP_RAW_POST_DATA);
  }
 
  $xml = @curl_exec($ch);
  curl_close($ch);
 
  header("Content-Type: text/xml");
  echo $xml;
  
?>