【发布时间】:2011-12-04 16:17:17
【问题描述】:
我正在尝试在 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 假设用户正在尝试运行安装,但事实并非如此。
任何关于如何解决这个问题的想法,因为其他人也会使用这个脚本?
【问题讨论】:
标签: php wordpress function curl