Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question & Suggestion: May you add atom feed reader beside RSS reader? #293

Open
serkanalgur opened this issue Feb 5, 2020 · 0 comments

Comments

@serkanalgur
Copy link

Hello there, Thank you for your small and such powerful framework. I use this framework to create simple sites/web-apps with ease. I have one suggestion.

Can you add atom reader beside RSS reader? I cloned RSS function and changed to atom reader. Here you go. I can create a pull request if you want to add this code to core.

	function atom($url,$max=10,$tags=NULL) {
		if (!$data=$this->request($url))
			return FALSE;
		// Suppress errors caused by invalid XML structures
		libxml_use_internal_errors(TRUE);
		$xml=simplexml_load_string($data['body'],
			NULL,LIBXML_NOBLANKS|LIBXML_NOERROR);
		if (!is_object($xml))
			return FALSE;
		$out=[];
		if (isset($xml->entry)) {
			$out['source']=(string)$xml->title;
			$max=min($max,count($xml->entry));
			for ($i=0;$i<$max;$i++) {
				$item=$xml->entry[$i];
				$list=[''=>NULL]+$item->getnamespaces(TRUE);
				$fields=[];
				foreach ($list as $ns=>$uri)
					foreach ($item->children($uri) as $key=>$val)
						$fields[$ns.($ns?':':'').$key]=(string)$val;
				$out['feed'][]=$fields;
			}
		}
		else
			return FALSE;
		Base::instance()->scrub($out,$tags);
		return $out;
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant