/libraries/joomla/facebook/link.php

https://gitlab.com/vitaliylukin91/text · PHP · 132 lines · 35 code · 11 blank · 86 comment · 0 complexity · f990de6b09fa27d3476e28a35e527032 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Platform
  4. * @subpackage Facebook
  5. *
  6. * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE
  8. */
  9. defined('JPATH_PLATFORM') or die();
  10. /**
  11. * Facebook API Link class for the Joomla Platform.
  12. *
  13. * @see http://developers.facebook.com/docs/reference/api/link/
  14. * @since 13.1
  15. */
  16. class JFacebookLink extends JFacebookObject
  17. {
  18. /**
  19. * Method to get a link. Requires authentication and read_stream permission for non-public links.
  20. *
  21. * @param string $link The link id.
  22. *
  23. * @return mixed The decoded JSON response or false if the client is not authenticated.
  24. *
  25. * @since 13.1
  26. */
  27. public function getLink($link)
  28. {
  29. return $this->get($link);
  30. }
  31. /**
  32. * Method to get a link's comments. Requires authentication and read_stream permission for non-public links.
  33. *
  34. * @param string $link The link id.
  35. * @param integer $limit The number of objects per page.
  36. * @param integer $offset The object's number on the page.
  37. * @param string $until A unix timestamp or any date accepted by strtotime.
  38. * @param string $since A unix timestamp or any date accepted by strtotime.
  39. *
  40. * @return mixed The decoded JSON response or false if the client is not authenticated.
  41. *
  42. * @since 13.1
  43. */
  44. public function getComments($link, $limit = 0, $offset = 0, $until = null, $since = null)
  45. {
  46. return $this->getConnection($link, 'comments', '', $limit, $offset, $until, $since);
  47. }
  48. /**
  49. * Method to comment on a link. Requires authentication and publish_stream permission.
  50. *
  51. * @param string $link The link id.
  52. * @param string $message The comment's text.
  53. *
  54. * @return mixed The decoded JSON response or false if the client is not authenticated.
  55. *
  56. * @since 13.1
  57. */
  58. public function createComment($link, $message)
  59. {
  60. // Set POST request parameters.
  61. $data = array();
  62. $data['message'] = $message;
  63. return $this->createConnection($link, 'comments', $data);
  64. }
  65. /**
  66. * Method to delete a comment. Requires authentication and publish_stream permission.
  67. *
  68. * @param string $comment The comment's id.
  69. *
  70. * @return mixed The decoded JSON response or false if the client is not authenticated.
  71. *
  72. * @since 13.1
  73. */
  74. public function deleteComment($comment)
  75. {
  76. return $this->deleteConnection($comment);
  77. }
  78. /**
  79. * Method to get link's likes. Requires authentication and read_stream permission for non-public links.
  80. *
  81. * @param string $link The link id.
  82. * @param integer $limit The number of objects per page.
  83. * @param integer $offset The object's number on the page.
  84. * @param string $until A unix timestamp or any date accepted by strtotime.
  85. * @param string $since A unix timestamp or any date accepted by strtotime.
  86. *
  87. * @return mixed The decoded JSON response or false if the client is not authenticated.
  88. *
  89. * @since 13.1
  90. */
  91. public function getLikes($link, $limit = 0, $offset = 0, $until = null, $since = null)
  92. {
  93. return $this->getConnection($link, 'likes', '', $limit, $offset, $until, $since);
  94. }
  95. /**
  96. * Method to like a link. Requires authentication and publish_stream permission.
  97. *
  98. * @param string $link The link id.
  99. *
  100. * @return boolean Returns true if successful, and false otherwise.
  101. *
  102. * @since 13.1
  103. */
  104. public function createLike($link)
  105. {
  106. return $this->createConnection($link, 'likes');
  107. }
  108. /**
  109. * Method to unlike a link. Requires authentication and publish_stream permission.
  110. *
  111. * @param string $link The link id.
  112. *
  113. * @return boolean Returns true if successful, and false otherwise.
  114. *
  115. * @since 13.1
  116. */
  117. public function deleteLike($link)
  118. {
  119. return $this->deleteConnection($link, 'likes');
  120. }
  121. }