创建小部件来计算未读垃圾邮件的垃圾邮件

时间:2014-01-10 05:43:07

标签: php email gmail gmail-imap gmail-contextual-gadgets

我想创建一个计算未读垃圾邮件的小部件,但脚本显示fullcount为0。 当我使用脚本收件箱时,它的工作正常

//function to get unread emails taking username and password as parameters
   function check_email($username, $password)
   { 
    $url = "https://mail.google.com/mail/feed/atom/spam"; 

    // sendRequest 
    $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, "");
    $curlData = curl_exec($curl);
    curl_close($curl);
    //returning retrieved feed
    return $curlData;

   }

/

     //making page to behave like xml document to show feeds
    header('Content-Type:text/xml; charset=UTF-8');
    //header('Content-Type:text/xml; charset=ISO-8859-1');
    //calling function
 echo $feed = check_email("myid@gmail.com", "mypassword");

0 个答案:

没有答案