Created
October 13, 2009 21:36
-
-
Save zackchandler/209590 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment