1<?php 2/** 3 * Horde_Service_Twitter_Favorites class for updating favorite tweets. 4 * 5 * Copyright 2009-2017 Horde LLC (http://www.horde.org/) 6 * 7 * @author Michael J Rubinsky <mrubinsk@horde.org> 8 * @license http://www.horde.org/licenses/bsd BSD 9 * @category Horde 10 * @package Service_Twitter 11 */ 12class Horde_Service_Twitter_Favorites 13{ 14 /** 15 * Endpoint for status api requests 16 * 17 * @var string 18 */ 19 private $_endpoint = 'https://api.twitter.com/1.1/favorites/'; 20 21 /** 22 * Format to use json or xml 23 * 24 * @var string 25 */ 26 private $_format = 'json'; 27 28 /** 29 * Constructor 30 * 31 * @param Horde_Service_Twitter $twitter 32 */ 33 public function __construct($twitter) 34 { 35 $this->_twitter = $twitter; 36 } 37 38 /** 39 * Obtain the requested status 40 * 41 * @return string The method call results. 42 */ 43 public function get() 44 { 45 $url = $this->_endpoint . 'list.' . $this->_format; 46 return $this->_twitter->request->post($url); 47 } 48 49 /** 50 * Destroy the specified favorite. 51 * 52 * @param string $id The status id 53 * 54 * @return string 55 */ 56 public function destroy($id) 57 { 58 $url = $this->_endpoint . 'destroy.' . $this->_format; 59 return $this->_twitter->request->post($url, array('id' => $id)); 60 } 61 62 /** 63 * Add a new favorite 64 * 65 * @param string $id The status id 66 * 67 * @return string The favorited tweet. 68 */ 69 public function create($id) 70 { 71 $url = $this->_endpoint . 'create.' . $this->_format; 72 return $this->_twitter->request->post($url, array('id' => $id)); 73 } 74 75}