开发者

PHP Proxy that handles both GET and POST without use of cURL

I've looked everywhere but can't find what I need so hence why I'm posting this question.

I'm looking for code for a PHP proxy to help me effectively do cross-domain jquery requests but have these requirements:

  1. Must be PHP
  2. Cannot use cUR开发者_运维百科L -- my server config doesn't support it. Presumably this leaves fopen() but I'm open to alternatives.
  3. Must support both GET and POST requests
  4. Support both responses for either XML and JSON

I'e searched high and low for a solution but always find solutions that use cURL or doesn't support POST.

I'm currently using this which doesn't work for POST:

header('Content-type: application/json');

$daurl = $_GET['url'];

$handle = fopen($daurl, "r");

if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
fclose($handle);
}


file_get_contents(). See Example #4 at the linked page (PHP online docs) on how to do 'custom' requests using streams for POST and arbitrary HTTP headers.


in other for you to get quick answer, you first need to do some work yourself, then when you get stuck, you can post it here. The question is too broad to be answered. you are requesting for a complete solution, you won't get it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜