File: edit.php

package info (click to toggle)
php-horde-feed 2.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,552 kB
  • ctags: 203
  • sloc: xml: 21,637; php: 786; jsp: 410; perl: 231; sh: 3; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,147 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
 * Example of editing an Atom post with Horde_Feed.
 *
 * @package Feed
 */

/* Get a Horde framework include_path set up. */
require 'Horde/Autoloader.php';

/* Load the feed we want to delete something from. */
try {
    $feed = Horde_Feed::readUri('http://www.example.com/Feed/');
} catch (Horde_Feed_Exception $e) {
    die('An error occurred loading the feed: ' . $e->getMessage() . "\n");
}

/* Grab the first entry in the feed. */
foreach ($feed as $entry) {
    break;
}

/* Display the entry's unchanged state. */
echo "entry last updated at: {$entry->updated()}\n";
echo "current EditURI is: {$entry->edit()}\n";

/* Just change the entry's properties directly. */
$entry->content = 'This is an updated post.';

/* Then save the changes. */
try {
    $entry->save();
} catch (Horde_Feed_Exception $e) {
    die('An error occurred saving changes: ' . $e->getMessage() . "\n");
}

/* Display the new state. The updated time and edit URI will have been
 * updated by the server, and $entry automatically picks up those
 * changes. */
echo "entry last updated at: {$entry->updated()}\n";
echo "new EditURI is: {$entry->edit()}\n";