/ Published in: PHP

A PHP proxy for jQuery AJAX cross-domain requisitions, created to support friendly-url API\\\\\\\'s.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $base_url = 'http://www.yoursite.com/api/'; $chamada = $chamada[2]; // if this php file is in a subdirectory you may change this key $url = $base_url.$chamada; if ($method == 'get') { if ($_SERVER['QUERY_STRING']) $url .= '?' . $_SERVER['QUERY_STRING']; } else { } ?> <!-- Example --> $.get('proxy.php/my_api_call'); $.post('proxy.php/my_post_api', {id:user_id});
Comments
