channel_property

(ReachRSS >= 0.91)
channel_property -- Get the string value of a channel property

Description

string channel_property ( string channel_url , string property_name )

Returns the value of the requested property_name from the specified channel_url. If the channel_url is invalid, channel_property() will return false. If the channel_url is valid, but the property_name you're requesting does not exist, channel_property() will return NULL.

Note that ReachRSS must already be subscribed to channel_url or this function will return false. To obtain a list of subscribed channels use the function channels() or check if the channel already exists using channel_exists().

Here is a complete list of channel properties that ReachRSS supports (as of the latest version). Note that this list is CaSe SeNsItIvE (title is valid, Title is not). Also note that simply because ReachRSS supports a property, does not mean that the channel you are retrieving a value from supports or lists that value. A return value of NULL means the channel is there but does not list the property you are trying to retrieve.

title       The value contained withing the channel's <title> element. This is the name of the channel eg: (string) "Wired News Headlines"
link   The value contained within the channel's <link> element. Usually this points to the homepage of the person or company that provides the RSS service.
eg: (string) "http://www.comicalert.com/"
description   The value contained within the channel's <description> element. Usually a short description of the channel's contents and/or the person/company providing it.
eg: (string) "Comic Alert! provides free RSS news feeds and Email alerts for over 7,000 online comics. Sign up in seconds and add your favorite comics to start receiving updates in your news reader or email client!"
webMaster   The value contained within the channel's <webMaster> element. According to the RSS specifications, this should be a valid email address, however some RSS channels list a web (http) address here.
eg: "rss@comicalert.com" or "http://www.wired.com/"
ttl   The value contained within the channel's <ttl> element. This value specifies how many minutes to wait before rechecking for new items.
eg: (string) "60"
pubDate   The value contained in the channel's <pubDate> element. This field (if available) will be the last time the channel was updated, and is a raw string date/time (not adjusted to your timezone).
eg: (string) "Fri, 6 Aug 2004 08:14:44 GMT"
dc:date   The value contained in the channel's <dc:date> element. Since Dublin Code date elements are so widely used, ReachRSS supports both. This value (if available) is the last time the channel was updated, and is a raw string date/time (not adjusted to your timezone).
eg: (string) "2004-07-21T05:10:00+00:00"
timestamp   This value is calculated from either pubDate or dc:date and is the Unix Timestamp value for the time the channel was last updated. This value is suitable for use in PHP's date() function.
eg: (int) 1091867662
image:url   The value contained within the channel's <image><url> element. This value points to an image to represent the channel. ReachRSS automatically caches channel images so that they're available locally. See the channel_image() function for details.
eg: (string) "http://www.comicalert.com/rss_logo.png"
image:link   The value contained within the channel's <image><link> element. This is the address that the RSS provider would like you to end up at when you click on their channel image.
eg: (string) "http://www.comicalert.com/"
image:width   The value contained within the channel's <image><width> element. Simply the width (in pixels) of the image.
eg: (string) "83"
image:height   The value contained within the channel's <image><height> element. Simply the height (in pixels) of the image.
eg: (string) "31"
image:title   The value contained within the channel's <image><title> element. This is the value that the RSS provider would like you to place in any alt="" or title="" tags when displaying the image.
eg: (string) "Comic Alert!"
     

Example 1. channel_property() example

$ReachRSS = new ReachRSS();
$ReachRSS->Startup();
$ReachRSS->add_channel("http://www.comicalert.com/public/popular24.xml");
$ChannelTitle = $ReachRSS->channel_property(
                     "http://www.comicalert.com/public/popular24.xml",
                     "title"
                    );
print $ChannelTitle;

This example will subscribe ReachRSS to the "most popular comics" feed at Comic Alert!, and then retrieve the title of the channel and print it.

Be careful not to confuse "" with NULL with FALSE. Here's how to tell the difference (notice the three equal signs (===) instead of usual two):

$pubDate = $ReachRSS->channel_property($ChannelURL,"pubDate");
if ($pubDate===FALSE) {
  // the $ChannelURL we specified was invalid
  exit;
}
if ($pubDate===NULL) {
  // channel exists but does not contain a pubDate element
  exit;
}
if ($pubDate==="") {
  // the $ChannelURL and $ItemID were valid, and the pubDate element 
  // exists, but the value is empty
  exit;
}

See also channels(), item_property(), channel_exists()

Back to Function List

 

Home | Features | Samples | Demo | Download | Register | Help / Support