• Hi!

    Im trying to create an rss feed from a gmail account. I used this snippet to fetch the main on a custom template:

    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("[email protected]", "password");
     echo $feed;

    This outputs the feed on a page great. But i need to create custom validated feed for it, how do i output that correctly?

    I tried to create a custom rss, se below, and point it to my template, but it doesn’t work. I guess i need to set up the template with correct rss code combined with the gmail snippet?

    add_action( 'after_setup_theme', 'my_rss_template' );
    /**
    * Register custom RSS template.
    */
    function my_rss_template() {
    add_feed( 'short', 'my_custom_rss_render' );
    }
    
    /**
    * Custom RSS template callback.
    */
    function my_custom_rss_render() {
    get_template_part( 'feed', 'short' );
    }

  • The topic ‘How do i create an rss feed from this page?’ is closed to new replies.