1: <?php
2: /**
3: * Notes methods.
4: *
5: * Note that these api calls are marked as BETA in the facebook docs.
6: *
7: * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
8: *
9: * @author Michael J. Rubinsky <mrubinsk@horde.org>
10: * @category Horde
11: * @package Service_Facebook
12: */
13: class Horde_Service_Facebook_Notes extends Horde_Service_Facebook_Base
14: {
15: /**
16: * Creates a note with the specified title and content.
17: *
18: * @param string $title Title of the note.
19: * @param string $content Content of the note.
20: * @param integer $uid The user for whom you are creating a note;
21: * defaults to current session user
22: *
23: * @return integer The ID of the note that was just created.
24: */
25: public function &create($title, $content, $uid = null)
26: {
27: // Session key is *required*
28: if (!$skey = $this->_facebook->auth->getSessionKey()) {
29: throw new Horde_Service_Facebook_Exception(
30: 'session_key is required',
31: Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
32: }
33: return $this->_facebook->callMethod(
34: 'notes.create',
35: array('uid' => $uid,
36: 'title' => $title,
37: 'content' => $content));
38: }
39:
40: /**
41: * Deletes the specified note.
42: *
43: * @param integer $note_id ID of the note you wish to delete
44: * @param integer $uid Owner of the note you wish to delete;
45: * defaults to current session user
46: *
47: * @return boolean
48: */
49: public function &delete($note_id, $uid = null)
50: {
51: // Session key is *required*
52: if (!$skey = $this->_facebook->auth->getSessionKey()) {
53: throw new Horde_Service_Facebook_Exception(
54: 'session_key is required',
55: Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
56: }
57: return $this->_facebook->callMethod(
58: 'notes.delete',
59: array('uid' => $uid,
60: 'note_id' => $note_id));
61: }
62:
63: /**
64: * Edits a note, replacing its title and contents with the title
65: * and contents specified.
66: *
67: * @param integer $note_id ID of the note you wish to edit
68: * @param string $title Replacement title for the note
69: * @param string $content Replacement content for the note
70: *
71: * @return boolean
72: */
73: public function &edit($note_id, $title, $content)
74: {
75: // Session key is *required*
76: if (!$skey = $this->_facebook->auth->getSessionKey()) {
77: throw new Horde_Service_Facebook_Exception(
78: 'session_key is required',
79: Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
80: }
81:
82: return $this->_facebook->callMethod(
83: 'notes.edit',
84: array('note_id' => $note_id,
85: 'title' => $title,
86: 'content' => $content));
87: }
88:
89: /**
90: * Retrieves all notes by a user. If note_ids are specified,
91: * retrieves only those specific notes by that user.
92: *
93: * @param integer $uid User whose notes you wish to retrieve
94: * @param array $note_ids (Optional) List of specific note
95: * IDs by this user to retrieve
96: *
97: * @return array A list of all of the given user's notes, or an empty list
98: * if the viewer lacks permissions or if there are no visible
99: * notes.
100: */
101: public function &get($uid, $note_ids = null)
102: {
103: // Session key is *required*
104: if (!$skey = $this->_facebook->auth->getSessionKey()) {
105: throw new Horde_Service_Facebook_Exception(
106: 'session_key is required',
107: Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
108: }
109:
110: return $this->_facebook->callMethod(
111: 'notes.get',
112: array('uid' => $uid,
113: 'note_ids' => json_encode($note_ids)));
114: }
115:
116: }