我多次尝试运行一个插件wordpress代码宽度卷曲登录,它总是返回以下消息:“您无权访问此页面。”我连接的帐户是管理员帐户。提前谢谢你
function curl_execute($login_user, $login_pass, $login_url, $visit_url, $http_agent, $cookie_file)
{
if (!function_exists('curl_init') || !function_exists('curl_exec')) {
return '{"error":"cUrl is not vailable in you PHP server."}';
}
// Preparing postdata for wordpress login
$data = "log=" . $login_user . "&pwd=" . $login_pass . "&wp-submit=Log%20In&redirect_to=" . $visit_url;
// Intialize cURL
$ch = curl_init();
// Url to use
curl_setopt($ch, CURLOPT_URL, $login_url);
// Set the cookies for the login in a cookie file.
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
// Set SSL to false
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// User agent
curl_setopt($ch, CURLOPT_USERAGENT, $http_agent);
// Maximum time cURL will wait for get response. in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// Return or echo the execution
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set Http referer.
curl_setopt($ch, CURLOPT_REFERER, $login_url);
// Post fields to the login url
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
// Save the return in a variable
$content = curl_exec($ch);
// Close the cURL.
curl_close($ch);
// You can echo or return the page data here.
return $content;
}
//call
$this->curl_execute($sync_login_user, $sync_login_pass, $sync_login_url, $sync_visit_url, $http_agent, $cookie_file);