Current time: 01-08-2010, 07:08 AM | Shoutbox Hello There, Guest! (LoginRegister)


Post Reply  Post Thread 
How To Query Google Feed Without Downloading Entire Feed?
Author Message
johnywhy
GB - Newbie
*


Posts: 3
Group: Registered
Joined: Dec 2007
Status: Offline
Reputation: 0
Post: #1
How To Query Google Feed Without Downloading Entire Feed?

is it possible to query a feed for a particular value, without
downloading the entire feed?

specifically, i want to query the following feed for LastBuildDate,
which is in the header of the feed:

http://gdata.youtube.com/feeds/api/playl...results=50

it appears at the bottom of this feed fragment:

<?xml version="1.0" encoding="utf-8" ?>
- <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005">
- <channel xmlns:cfi="http://www.microsoft.com/schemas/rss/core/2005/
internal" cfi:lastdownloaderror="None">
<link>http://www.youtube.com/view_play_list?p=9A337BB0628CF018</
link>
- <image>
<url>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</url>
<title>Impeach</title>
<link>http://www.youtube.com/view_play_list?p=9A337BB0628CF018</
link>
</image>
<cf:guid isPermaLink="false">http://gdata.youtube.com/feeds/api/
playlists/9A337BB0628CF018</cf:guid>
<atom:updated>2007-12-05T09:45:26Z</atom:updated>
<lastBuildDate>Wed, 05 Dec 2007 09:45:26 GMT</lastBuildDate>

unknown browser unknown system
Browser e O.S.: 
08-12-2007 11:04 PM
Find all posts by this user Quote this message in a reply
Langy
Administrator
*******


Posts: 8.460
Group: Administrators
Joined: Sep 2007
Status: Offline
Reputation: 10
Post: #2
RE: How To Query Google Feed Without Downloading Entire Feed?

Hi,

u must use this code and customize it with your feed url

Code:
<?php

$insideitem2 = false;
$tag2 = "";
$title2 = "";
$description2 = "";
$link2 = "";

function startElement2($parser2, $name2, $attrs2) {
global $insideitem2, $tag2, $title2, $description2, $link2;
if ($insideitem2) {
$tag2 = $name2;
} elseif (strtolower($name2) == "item") {
$insideitem2 = true;
}
}

function endElement2($parser2, $name2) {
global $insideitem2, $tag2, $title2, $description2, $link2;
if (strtolower($name2) == "item") {
printf("<strong><a href='%s' title='Click to view' target='_blank'>%s</a></strong><div>",
trim($link2),trim($title2),trim($title2));
printf("%s</div><br />",trim($description2));
$title2 = "";
$description2 = "";
$link2 = "";
$insideitem2 = false;
}
}

function characterData2($parser2, $data2) {
global $insideitem2, $tag2, $title2, $description2, $link2;
if ($insideitem2) {
switch (strtolower($tag2)) {
case "title":
$title2 .= $data2;
break;
case "description":
$description2 .= $data2;
break;
case "link":
$link2 .= $data2;
break;
}
}
}

$xml_parser2 = xml_parser_create();
xml_set_element_handler($xml_parser2, "startElement2", "endElement2");
xml_set_character_data_handler($xml_parser2, "characterData2");

$fp2 = fopen("http://feeds.feedburner.com/Googlebig","r")

or die("Error reading RSS data.");
while ($data2 = fread($fp2, 4096))
xml_parse($xml_parser2, $data2, feof($fp2))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser2)),
xml_get_current_line_number($xml_parser2)));
fclose($fp2);
xml_parser_free($xml_parser2);

?>


u must replace this

Code:
$fp2 = fopen("http://feeds.feedburner.com/Googlebig","r")


with this

Code:
$fp2 = fopen("http://gdata.youtube.com/feeds/api/playlists/9A337BB0628CF018?start-index=1&max-results=50","r")


"There is no patch for human stupidity" - K. D. M.
unknown browser unknown system
Browser e O.S.: 
09-12-2007 05:54 PM
Visit this user's website Find all posts by this user Quote this message in a reply
johnywhy
GB - Newbie
*


Posts: 3
Group: Registered
Joined: Dec 2007
Status: Offline
Reputation: 0
Post: #3
RE: How To Query Google Feed Without Downloading Entire Feed?

many thanks, but i've found php5 "get_headers" function. it does the trick.

now my difficult question is "how to call an external PHP file asynchonously WITHOUT shelling out to the system?

i don't have shell access on my shared hosting service, so i cannot use "popen". at least, popen is not working for me here. am i doing something wrong?

PHP Code:
<?php

$myhandle 
popen("http://picnictoimpeach.us/remote.php5");

?>

This post was last modified: 09-12-2007 08:43 PM by johnywhy.

unknown browser unknown system
Browser e O.S.: 
09-12-2007 08:21 PM
Find all posts by this user Quote this message in a reply
Langy
Administrator
*******


Posts: 8.460
Group: Administrators
Joined: Sep 2007
Status: Offline
Reputation: 10
Post: #4
RE: How To Query Google Feed Without Downloading Entire Feed?

ok well,

u can use api feeds of Google in ajax

This is an example:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google AJAX Feed API - Simple Example</title>
    <script type="text/javascript" src="http://www.google.com/jsapi?key=***YOUR KEY****"></script>
    <script type="text/javascript">

    google.load("feeds", "1");

    function initialize() {
      var feed = new google.feeds.Feed("****FEED RSS****");
      feed.load(function(result) {
        if (!result.error) {
          var container = document.getElementById("feed");
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            var div = document.createElement("div");
            div.appendChild(document.createTextNode(entry.title));
            container.appendChild(div);
          }
        }
      });
    }
    google.setOnLoadCallback(initialize);

    </script>
  </head>
  <body>
    <div id="feed"></div>
  </body>
</html>


You must change this with your key:

Code:
<script type="text/javascript" src="http://www.google.com/jsapi?key=***YOUR KEY****"></script>


Go here for generation key page http://code.google.com/apis/ajaxfeeds/signup.html


"There is no patch for human stupidity" - K. D. M.
unknown browser unknown system
Browser e O.S.: 
09-12-2007 09:22 PM
Visit this user's website Find all posts by this user Quote this message in a reply
johnywhy
GB - Newbie
*


Posts: 3
Group: Registered
Joined: Dec 2007
Status: Offline
Reputation: 0
Post: #5
RE: How To Query Google Feed Without Downloading Entire Feed?

sorry to confuse the issue, but i dont need the google api stuff now. i'm using a simple php5 "get_headers". but thanks for the awesome response!

however, if you can tell me what's wrong with my script above, that would be fantastic, but it's off-topic.

This post was last modified: 09-12-2007 09:41 PM by johnywhy.

unknown browser unknown system
Browser e O.S.: 
09-12-2007 09:40 PM
Find all posts by this user Quote this message in a reply
Langy
Administrator
*******


Posts: 8.460
Group: Administrators
Joined: Sep 2007
Status: Offline
Reputation: 10
Post: #6
RE: How To Query Google Feed Without Downloading Entire Feed?

sorry but i dont use php5


"There is no patch for human stupidity" - K. D. M.
unknown browser unknown system
Browser e O.S.: 
09-12-2007 10:26 PM
Visit this user's website Find all posts by this user Quote this message in a reply
free0
GB - Junior Member
**


Posts: 24
Group: Registered
Joined: Apr 2010
Status: Offline
Reputation: 0
Post: #7
RE: How To Query Google Feed Without Downloading Entire Feed?

thank's men ...
we can prove the best ...and mor time ...we can try again
sharing your help and go...

Internet Explorer Windows XP/2003
Browser e O.S.: 
24-04-2010 10:17 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Google MAP e inserimento post mattej 9 1.123 24-04-2010 10:09 PM
Last Post: free0
  Google Maps API + Youtube Video Langy 0 491 10-09-2007 06:17 PM
Last Post: Langy

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites