amfPHP 函数输入问题

发布于 2024-08-13 07:02:20 字数 262 浏览 2 评论 0原文

我正在编写一个 amfPHP 函数,它应该接受字符串输入。它接受字母数字字符没有问题,但不幸的是,如果我发送“2.UgnFl4kAWovazp_tVo6fHg__.86400.1260025200-571701419”作为参数,它返回的数据为“2”。

这是函数(如您所见,非常简单)

function checkOpenSession($guid, $session_key) {
        return $session_key;
}

I'm writing an amfPHP function which should take string input. It takes alphanumeric characters without a problem, but unfortunately it returns data as "2" if I send "2.UgnFl4kAWovazp_tVo6fHg__.86400.1260025200-571701419" as parameter.

here is the function (real simple as you can see)

function checkOpenSession($guid, $session_key) {
        return $session_key;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

瀟灑尐姊 2024-08-20 07:02:20

要绕过此服务浏览器错误,如果您希望参数上有一个字符串并且该字符串以数字开头,请在服务浏览器上双引号您的条目。我在通过服务浏览器测试某些方法时遇到了同样的问题,并且工作正常。

To bypass this service browser bug, double quote your entry on the service browser if you expect a string on an argument and this string starts with a number. I was having the same problem testing some methods via service browser and it worked fine.

晨曦÷微暖 2024-08-20 07:02:20

我只是通过简单的设置尝试了这一点,然后将结果从服务浏览器写入文件,这对我来说似乎没问题。所以问题似乎出在调用端。

另一种可能性是 amfphp 由于前导整数而将返回值的数据类型从字符串更改为 int。尝试在返回字符串的开头放置一些字母数字字符,看看会发生什么。

I just tried this with a simple setup, and just writing the results to a file from the service browser and it seems to be ok for me. So the problem would seem to be in the calling end.

Another possibility is that amfphp changes the datatype of the returned value from a string to an int because of the leading integer. Try putting a some alphanumeric character at the start of the return string and see what that does.

没有伤那来痛 2024-08-20 07:02:20

此行为实际上存在于 AMFPHP 服务浏览器中(bug),因此很容易将其误认为是 AMFPHP 正在将数字开头的字符串转换为 int。然而问题出在发送代码上。例如,通过 json 网关发送 urlencoded 字符串可以正常工作(Objective C 代码):

NSString *theUrl = [[NSString alloc] initWithFormat:@"%@/modules/amfphp/amfphp/json.php/MysqlRemoting.checkAuth/%@/%@/1", kServerBaseUrl, userName, passMD5];
NSString *encodedUrl = [theUrl stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];

其中 passMD5 可能有一个前导数字。但是,如果我在服务浏览器中为 checkAuth 方法输入适当的值,它就会被破坏。

[编辑]

$value = urldecode($value);
if($value != "") {
if($value[0] != '[' && $value[0] != '{' && $value != "null" && $value != "false" && $value != "true") {
$hasAlpha = false;
//check to see if it is a number
$sl = strlen($value);
for ($i = 0; $i < $sl; $i++) {
    $char1 = ord($value[$i]);
    if($char1 >= 0x30 && $char1 <= 0x39) {
    //Then this is a number
    } else { //Else leave value as is */
    $hasAlpha = true;
    }
    }
    if (!$hasAlpha) $value = json_decode($value, true);
}
        else
        {
            $value = json_decode($value, true);
        }
    }

This behavior is actually present in the AMFPHP service browser(bug), so it is easy to mistake it as the AMFPHP that is converting number-leading strings to int. However the problem is in the sending code. For instance sending a urlencoded string through the json gateway works properly (Objective C code):

NSString *theUrl = [[NSString alloc] initWithFormat:@"%@/modules/amfphp/amfphp/json.php/MysqlRemoting.checkAuth/%@/%@/1", kServerBaseUrl, userName, passMD5];
NSString *encodedUrl = [theUrl stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];

Where passMD5 may have a leading number. But if I enter appropriate values for the checkAuth method in the service browser, it is broken.

[edit]

$value = urldecode($value);
if($value != "") {
if($value[0] != '[' && $value[0] != '{' && $value != "null" && $value != "false" && $value != "true") {
$hasAlpha = false;
//check to see if it is a number
$sl = strlen($value);
for ($i = 0; $i < $sl; $i++) {
    $char1 = ord($value[$i]);
    if($char1 >= 0x30 && $char1 <= 0x39) {
    //Then this is a number
    } else { //Else leave value as is */
    $hasAlpha = true;
    }
    }
    if (!$hasAlpha) $value = json_decode($value, true);
}
        else
        {
            $value = json_decode($value, true);
        }
    }
月亮是我掰弯的 2024-08-20 07:02:20

双引号你的字符串...这样就可以解决问题。

double quote your strings... that will work it out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文