尝试在 WordPress 中运行 CURL 脚本

发布于 2024-12-09 02:45:22 字数 1547 浏览 0 评论 0原文

我正在尝试在 WordPress 中运行 CURL 脚本,但遇到问题。

当我测试它时,我收到 500 内部错误,因为 WP 更改了 URL。

所以脚本位于 www.site.com/curl_script.php - 当我测试该脚本时(导航到 www.site.com/curl_script.php),我最终会访问 www.site.com/curl_script.php/wp-admin /install.php 返回 500 内部错误。

现在,在研究了脚本之后,我注意到了这个问题。这似乎是我正在运行的一个函数(curl 函数),它导致 wordpress 将我带到该 url。

我遇到了与此类似的问题,但已通过简单地更改函数名称来解决它,但这似乎不再起作用。

函数:

  function verify_user($ref, $username, $uu_name){






    $ch = curl_init($server_root);
    curl_setopt($ch,CURLOPT_URL,"http://site.com/con1.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
    curl_setopt($ch, CURLOPT_POST, 1);

    $result = curl_exec($ch);

    $data = json_decode($result);

    global $ref_;

    $ref_ = $data->ref_id;


//fetch some more info

    $chh = curl_init($server_root);
    curl_setopt($chh,CURLOPT_URL,"http://site.com/con2.php");

    curl_setopt($chh, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($chh, CURLOPT_POST, 1);

    $resultt_2 = curl_exec($chh);

    $data_custt = json_decode($resultt_2);



    $cust_st = $data__->user_status;

    if ($cust_st == "FAILED"){

    echo "this is bad";


    }

    elseif ($cust_st == "PASSED") {

    echo "this is good";

    }
    }
    }

现在,当我调用此函数时:

verify_user_info($ref, $username, $uu_name);

Wordpress 会播放...

但是当我忽略该函数(不调用它)时,一切正常。

WP 似乎假设用户正在尝试运行安装,但事实并非如此。

关于如何动态修复此问题的任何想法,因为其他人也将使用此脚本?

I'm trying to run a CURL script in wordpress but I'm having a problem.

When i test it, i get a 500 internal error as WP changes the URL.

So the script is at www.site.com/curl_script.php - When i test that (navigate to www.site.com/curl_script.php) I end up going to www.site.com/curl_script.php/wp-admin/install.php which returns a 500 internal error.

Now after playing around with the script, I've noticed the problem. It seems to be a function that I'm running (the curl function) thats causing wordpress to take me to that url.

Ive had similar issues to this but have managed to fix it by simply changing the names of the functions, but this doesn't seem to work anymore.

The function:

  function verify_user($ref, $username, $uu_name){






    $ch = curl_init($server_root);
    curl_setopt($ch,CURLOPT_URL,"http://site.com/con1.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
    curl_setopt($ch, CURLOPT_POST, 1);

    $result = curl_exec($ch);

    $data = json_decode($result);

    global $ref_;

    $ref_ = $data->ref_id;


//fetch some more info

    $chh = curl_init($server_root);
    curl_setopt($chh,CURLOPT_URL,"http://site.com/con2.php");

    curl_setopt($chh, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($chh, CURLOPT_POST, 1);

    $resultt_2 = curl_exec($chh);

    $data_custt = json_decode($resultt_2);



    $cust_st = $data__->user_status;

    if ($cust_st == "FAILED"){

    echo "this is bad";


    }

    elseif ($cust_st == "PASSED") {

    echo "this is good";

    }
    }
    }

Now when i call this function:

verify_user_info($ref, $username, $uu_name);

Wordpress plays up...

But when i leave the function out (don't call it), everything works fine.

It seems that WP is assuming the user is attempting to run the installation, when that's not the case.

Any ideas on how to fix this, dynamically as others will use this script too?

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

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

发布评论

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

评论(1

优雅的叶子 2024-12-16 02:45:22

如果听起来您以某种方式被重定向,即使如果未设置 CURLOPT_FOLLOWLOCATION 则不应该被重定向。尝试使用curl_getinfo函数来调试正在访问的URL。

If sounds like you are getting redirected somehow, even though should shouldn't be if CURLOPT_FOLLOWLOCATION is not set. Try using the curl_getinfo function to debug the URL that is being accessed.

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