How to use curl option to scan the result

Alles, was PHP betrifft, kann hier besprochen werden.

How to use curl option to scan the result

Postby ym_chaitu » 23. November 2009 12:51

Hai
i am using the curl option to validate the site for the rss feed.
my code is

Code: Select all
<?php
// create a new cURL resource
$ch = curl_init();
$demo='http://chaitu09986025424.blog.co.in/feed/rss/';
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://validator.w3.org/feed/check.cgi?url=$demo");
curl_setopt($ch, CURLOPT_HEADER, false);

// grab URL and pass it to the browser
curl_exec($ch);
echo $info['http_code'] . " " . $http_codes[$info['http_code']];
// close cURL resource, and free up system resources
curl_close($ch);
?>


now the problem is that how do i read the file and pass the parameters...
the result of this would be

Congratulations!
This is a valid RSS feed.

Recommendations
This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

•line 11, column 107: Self reference doesn't match document location [help]

... rel="self" type="application/rss+xml" /> ^Source: http://chaitu09986025424.blog.co.in/feed/rss/
1.<?xml version="1.0" encoding="UTF-8"?>
2.<rss version="2.0"
3.xmlns:content="http://purl.org/rss/1.0/modules/content/"
4.xmlns:wfw="http://wellformedweb.org/CommentAPI/"
5.xmlns:dc="http://purl.org/dc/elements/1.1/"
6.xmlns:atom="http://www.w3.org/2005/Atom"
7.>
8.
9.<channel>
10.<title>Chaitu's</title>
11.<atom:link href="http://chaitu09986025424.blog.co.in/wp-rss2.php" rel="self" type="application/rss+xml" />
12.<link>http://chaitu09986025424.blog.co.in</link>
13.<description>Know about the World and gain some Knowledge</description>
14.<pubDate>Fri, 20 Nov 2009 11:18:56 +0000</pubDate>

how do i pass the This is a valid RSS feed. data in code so that i can validate the given url..

please some body help me on this..
--
Chaitanya Babu Yanamadala
www.drvirusindia.co.cc
User avatar
ym_chaitu
 
Posts: 33
Joined: 13. November 2009 08:26
Location: Bangalore,India

Re: How to use curl option to scan the result

Postby Wiedmann » 23. November 2009 22:06

I guess you want do something like:
Code: Select all
<?php
$feeduri 
= 'http://chaitu09986025424.blog.co.in/fed/rss/';

$query = http_build_query(array(
    'output' => 'soap12',
    'url'    => $feeduri
), '', '&');

$doc = new DOMDocument();
if (!@$doc->load("http://validator.w3.org/feed/check.cgi?{$query}")) {
    die('Error during validating the feed.');
}

$validity = $doc->getElementsByTagName('validity');
$validity = ($validity->length && ($validity->item(0)->nodeValue == 'true')) ? true : false;

var_dump($validity);
?>
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to use curl option to scan the result

Postby ym_chaitu » 24. November 2009 06:35

hai
10q for your help
but i found an alternative for this one..
to use the following
Code: Select all
simplexml_load_file("$data")


which will do the needful..
--
Chaitanya Babu Yanamadala
www.drvirusindia.co.cc
User avatar
ym_chaitu
 
Posts: 33
Joined: 13. November 2009 08:26
Location: Bangalore,India


Return to PHP

Who is online

Users browsing this forum: No registered users and 7 guests