Revision: 32958
Updated Code
at October 5, 2010 05:49 by hisamu
Updated Code
<?php
$base_url = 'http://www.yoursite.com/api/';
$chamada = explode('/', $_SERVER['PHP_SELF']);
$chamada = $chamada[2]; // if this php file is in a subdirectory you may change this key
$url = $base_url.$chamada;
$method = (!empty($_POST)) ? 'post' : 'get';
$ch = curl_init();
if ($method == 'get')
{
if ($_SERVER['QUERY_STRING']) $url .= '?' . $_SERVER['QUERY_STRING'];
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
}
else
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_setopt($ch, CURLOPT_URL, $url);
}
$data = curl_exec($ch);
curl_close($ch);
?>
<!-- Example -->
$.get('proxy.php/my_api_call');
$.post('proxy.php/my_post_api', {id:user_id});
Revision: 32957
Updated Code
at October 5, 2010 05:48 by hisamu
Updated Code
<?php
$base_url = 'http://www.yoursite.com/api/';
$chamada = explode('/', $_SERVER['PHP_SELF']);
$chamada = $chamada[2]; // if this php file is in a subdirectory you may change this key
$url = $base_url.$chamada;
$method = (!empty($_POST)) ? 'post' : 'get';
$ch = curl_init();
if ($method == 'get')
{
if ($_SERVER['QUERY_STRING']) $url .= '?' . $_SERVER['QUERY_STRING'];
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
}
else
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_setopt($ch, CURLOPT_URL, $url);
}
$data = curl_exec($ch);
curl_close($ch);
?>
<!-- Example -->
$.get('proxy.php/my_api_call');
$.post('proxy.php/my_post_api', {id:user_id})
Revision: 32956
Updated Code
at October 5, 2010 05:47 by hisamu
Updated Code
<?php
$base_url = 'http://www.yoursite.com/api/';
$chamada = explode('/', $_SERVER['PHP_SELF']);
$chamada = $chamada[2]; // if this php file is in a subdirectory you may change this key
$url = $base_url.$chamada;
$method = (!empty($_POST)) ? 'post' : 'get';
$ch = curl_init();
if ($method == 'get')
{
if ($_SERVER['QUERY_STRING']) $url .= '?' . $_SERVER['QUERY_STRING'];
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
}
else
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_setopt($ch, CURLOPT_URL, $url);
}
$data = curl_exec($ch);
curl_close($ch);
?>
<!-- Example -->
$.get('proxy.php/my_api_call');
Revision: 32955
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 5, 2010 05:44 by hisamu
Initial Code
<?php
$base_url = 'http://www.yoursite.com/api/';
$chamada = explode('/', $_SERVER['PHP_SELF']);
$chamada = $chamada[2]; // if this php file is in a subdirectory you may change this key
$url = $base_url.$chamada;
$method = (!empty($_POST)) ? 'post' : 'get';
$ch = curl_init();
if ($method == 'get')
{
if ($_SERVER['QUERY_STRING']) $url .= '?' . $_SERVER['QUERY_STRING'];
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
}
else
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_setopt($ch, CURLOPT_URL, $url);
}
$data = curl_exec($ch);
curl_close($ch);
?>
Initial URL
http://www.lsouza.pro.br
Initial Description
A PHP proxy for jQuery AJAX cross-domain requisitions, created to support friendly-url API\\\\\\\'s.
Initial Title
Jquery AJAX cross-domain proxy with php
Initial Tags
ajax, php, jquery
Initial Language
PHP