English 中文(简体)
在露天时,无法沿用LURL的所在地(URL)——A/60/8呼吁失败
原标题:Unable to follow a location (URL) using cURL when open_basedir is set - API callback failing

Existing method of posting values to API
As per the API documentation, a form has to be posted to the API URL (method="POST" and action="API_URL") with some input fields and a customer token field. The API processes and then posts response to a callback.php file on my server (fixed - can t change it). The page redirects to the API URL and then comes back to callback.php. I can access the posted vals using $_POST in that file. That s all about the existing method and it works fine.

Server side post to hide the customer token
For security reasons, I am trying to post from server side this time.

The Problem
Callback is not happening (code inside callback.php file not executing).

在辛勤地把URL调往APIC并接受回击之后,我认识到,开端ir子是安装在我的服务器上,预定在服务器上,。 CURLOPT_FOLOWLOCATION。 我发现,即使设定了<代码>安全_mode>,但似乎仍能完成张贴的以下代码:<>On或 open_basedir,条件是:

we know generally where we ll be redirected to

Please go through the code below and tell me what is meant here by if we know generally where we ll be redirected to. Is it the URL where the API will redirect to after the processing completes? Then yes I know, it has to send callback to a callback.php file on my server, but that is not happening. :-

function curl($url, $postVars)
{
    $go = curl_init($url);
    curl_setopt ($go, CURLOPT_URL, $url);
    curl_setopt($go, CURLOPT_VERBOSE, 1);

    //follow on location problems
    if (ini_get( open_basedir ) ==    && (ini_get( safe_mode )==  Off ))
    {
        curl_setopt ($go, CURLOPT_FOLLOWLOCATION, $l);
        $syn = curl_exec($go);
        if(curl_error($go))
            return false;
    }
    else
        $syn = curl_redir_exec($go, $postVars);
    curl_close($go);
    return $syn;
}

function curl_redir_exec($ch, $postVars)
{
    static $curl_loops = 0;
    static $curl_max_loops = 20;
    if ($curl_loops++>= $curl_max_loops)
    {
        $curl_loops = 0;
        return FALSE;
    }
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    $data = curl_exec($ch);
    if(curl_error($ch))
        return false;
    list($header, $data) = explode("

", $data, 2);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    $redirect_page = "[0-9]*.html";
    $base_redirect = "http://example.com/";

    if ($http_code == 301 || $http_code == 302)
    {
        $matches = array();
        $pregs = eregi($redirect_page, $data, $matches);
        $new_url = $base_redirect . $matches[0];
        if (!$new_url)
        {
            //couldn t process the url to redirect to
            $curl_loops = 0;
            return $data;
        }
        curl_setopt($ch, CURLOPT_URL, $new_url);

        return curl_redir_exec($ch, $postVars);
    }
    else
    {
        $curl_loops=0;
        return $data;
    }
}

在操作该代码时,该编码进入了$_code既不是301,也不是302<>。 (此处为200)。 印刷数据如下:

HTTP/1.1 200 OK Date: Wed, 01 Sep 2010 10:02:44 GMT Server: Apache/2 X-Powered-By: PHP/5.2.11 Content-Length: 0 Connection: close Content-Type: text/html

Help
Help me guys..
Any code changes to this needed?
Will cURL not work in my case? (it is an asynchronous API - it triggers the callback when it s done. The original request does not receive a return value in this kind of setup.)

Thanks Sandeepan

问题回答

您应核实LL的要求(echo$new_url);





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...