我正在尝试使用一个函数从gmail dress创建rss提要。如果我把它放在函数中,它就会工作。php,但正如预期的那样,它取代了我的网站成为rssfeed。如何将其放置在独立页面中,例如/gmailrss?
代码段(如果需要):
function checkGmail($username, $password)
{
$url = "https://mail.google.com/mail/feed/atom";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_ENCODING, "");
$mailData = curl_exec($curl);
curl_close($curl);
return $mailData;
}
header(\'Content-Type:text/xml; charset=UTF-8\');
$feed = checkGmail("gmail", "password");
echo $feed;