Source for file event.php

Documentation is available at event.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Facebook
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die();
  11.  
  12.  
  13. /**
  14.  * Facebook API User class for the Joomla Platform.
  15.  *
  16.  * @package     Joomla.Platform
  17.  * @subpackage  Facebook
  18.  *
  19.  * @see         http://developers.facebook.com/docs/reference/api/event/
  20.  * @since       13.1
  21.  */
  22. {
  23.     /**
  24.      * Method to get information about an event visible to the current user. Requires authentication.
  25.      *
  26.      * @param   string  $event  The event id.
  27.      *
  28.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  29.      *
  30.      * @since   13.1
  31.      */
  32.     public function getEvent($event)
  33.     {
  34.         return $this->get($event);
  35.     }
  36.  
  37.     /**
  38.      * Method to get the event's wall. Requires authentication.
  39.      *
  40.      * @param   string   $event   The event id.
  41.      * @param   integer  $limit   The number of objects per page.
  42.      * @param   integer  $offset  The object's number on the page.
  43.      * @param   string   $until   A unix timestamp or any date accepted by strtotime.
  44.      * @param   string   $since   A unix timestamp or any date accepted by strtotime.
  45.      *
  46.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  47.      *
  48.      * @since   13.1
  49.      */
  50.     public function getFeed($event$limit 0$offset 0$until null$since null)
  51.     {
  52.         return $this->getConnection($event'feed'''$limit$offset$until$since);
  53.     }
  54.  
  55.     /**
  56.      * Method to post a link on event's feed which the current_user is or maybe attending. Requires authentication and publish_stream permission.
  57.      *
  58.      * @param   string  $event    The event id.
  59.      * @param   string  $link     Link URL.
  60.      * @param   string  $message  Link message.
  61.      *
  62.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  63.      *
  64.      * @since   13.1
  65.      */
  66.     public function createLink($event$link$message null)
  67.     {
  68.         // Set POST request parameters.
  69.         $data array();
  70.         $data['link'$link;
  71.         $data['message'$message;
  72.  
  73.         return $this->createConnection($event'feed'$data);
  74.     }
  75.  
  76.     /**
  77.      * Method to delete a link. Requires authentication and publish_stream permission.
  78.      *
  79.      * @param   mixed  $link  The Link ID.
  80.      *
  81.      * @return  boolean   Returns true if successful, and false otherwise.
  82.      *
  83.      * @since   13.1
  84.      */
  85.     public function deleteLink($link)
  86.     {
  87.         return $this->deleteConnection($link);
  88.     }
  89.  
  90.     /**
  91.      * Method to post on event's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
  92.      *
  93.      * @param   string  $event        The event id.
  94.      * @param   string  $message      Post message.
  95.      * @param   string  $link         Post URL.
  96.      * @param   string  $picture      Post thumbnail image (can only be used if link is specified)
  97.      * @param   string  $name         Post name (can only be used if link is specified).
  98.      * @param   string  $caption      Post caption (can only be used if link is specified).
  99.      * @param   string  $description  Post description (can only be used if link is specified).
  100.      * @param   array   $actions      Post actions array of objects containing name and link.
  101.      *
  102.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  103.      *
  104.      * @since   13.1
  105.      */
  106.     public function createPost($event$message null$link null$picture null$name null$caption null,
  107.         $description null$actions null)
  108.     {
  109.         // Set POST request parameters.
  110.         $data array();
  111.         $data['message'$message;
  112.         $data['link'$link;
  113.         $data['name'$name;
  114.         $data['caption'$caption;
  115.         $data['description'$description;
  116.         $data['actions'$actions;
  117.         $data['picture'$picture;
  118.  
  119.         return $this->createConnection($event'feed'$data);
  120.     }
  121.  
  122.     /**
  123.      * Method to delete a post. Note: you can only delete the post if it was created by the current user.
  124.      * Requires authentication and publish_stream permission.
  125.      *
  126.      * @param   string  $post  The Post ID.
  127.      *
  128.      * @return  boolean   Returns true if successful, and false otherwise.
  129.      *
  130.      * @since   13.1
  131.      */
  132.     public function deletePost($post)
  133.     {
  134.         return $this->deleteConnection($post);
  135.     }
  136.  
  137.     /**
  138.      * Method to post a status message on behalf of the user on the event's wall. Requires authentication and publish_stream permission.
  139.      *
  140.      * @param   string  $event    The event id.
  141.      * @param   string  $message  Status message content.
  142.      *
  143.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  144.      *
  145.      * @since   13.1
  146.      */
  147.     public function createStatus($event$message)
  148.     {
  149.         // Set POST request parameters.
  150.         $data array();
  151.         $data['message'$message;
  152.  
  153.         return $this->createConnection($event'feed'$data);
  154.     }
  155.  
  156.     /**
  157.      * Method to delete a status. Note: you can only delete the post if it was created by the current user.
  158.      * Requires authentication and publish_stream permission.
  159.      *
  160.      * @param   string  $status  The Status ID.
  161.      *
  162.      * @return  boolean   Returns true if successful, and false otherwise.
  163.      *
  164.      * @since   13.1
  165.      */
  166.     public function deleteStatus($status)
  167.     {
  168.         return $this->deleteConnection($status);
  169.     }
  170.  
  171.     /**
  172.      * Method to get the list of invitees for the event. Requires authentication and user_events or friends_events permission.
  173.      *
  174.      * @param   string   $event   The event id.
  175.      * @param   integer  $limit   The number of objects per page.
  176.      * @param   integer  $offset  The object's number on the page.
  177.      *
  178.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  179.      *
  180.      * @since   13.1
  181.      */
  182.     public function getInvited($event$limit 0$offset 0)
  183.     {
  184.         return $this->getConnection($event'invited'''$limit$offset);
  185.     }
  186.  
  187.     /**
  188.      * Method to check if a user is invited to the event. Requires authentication and user_events or friends_events permission.
  189.      *
  190.      * @param   string  $event  The event id.
  191.      * @param   mixed   $user   Either an integer containing the user ID or a string containing the username.
  192.      *
  193.      * @return  array   The decoded JSON response or an empty array if the user is not invited.
  194.      *
  195.      * @since   13.1
  196.      */
  197.     public function isInvited($event$user)
  198.     {
  199.         return $this->getConnection($event'invited/' $user);
  200.     }
  201.  
  202.     /**
  203.      * Method to invite users to the event. Requires authentication and create_event permission.
  204.      *
  205.      * @param   string  $event  The event id.
  206.      * @param   string  $users  Comma separated list of user ids.
  207.      *
  208.      * @return  boolean   Returns true if successful, and false otherwise.
  209.      *
  210.      * @since   13.1
  211.      */
  212.     public function createInvite($event$users)
  213.     {
  214.         // Set POST request parameters.
  215.         $data array();
  216.         $data['users'$users;
  217.  
  218.         return $this->createConnection($event'invited'$data);
  219.     }
  220.  
  221.     /**
  222.      * Method to delete a invitation. Note: you can only delete the invite if the current user is the event admin.
  223.      * Requires authentication and rsvp_event permission.
  224.      *
  225.      * @param   string  $event  The event id.
  226.      * @param   string  $user   The user id.
  227.      *
  228.      * @return  boolean   Returns true if successful, and false otherwise.
  229.      *
  230.      * @since   13.1
  231.      */
  232.     public function deleteInvite($event$user)
  233.     {
  234.         return $this->deleteConnection($event'invited/' $user);
  235.     }
  236.  
  237.     /**
  238.      * Method to get the list of attending users. Requires authentication and user_events or friends_events permission.
  239.      *
  240.      * @param   string   $event   The event id.
  241.      * @param   integer  $limit   The number of objects per page.
  242.      * @param   integer  $offset  The object's number on the page.
  243.      *
  244.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  245.      *
  246.      * @since   13.1
  247.      */
  248.     public function getAttending($event$limit 0$offset 0)
  249.     {
  250.         return $this->getConnection($event'attending'''$limit$offset);
  251.     }
  252.  
  253.     /**
  254.      * Method to check if a user is attending an event. Requires authentication and user_events or friends_events permission.
  255.      *
  256.      * @param   string  $event  The event id.
  257.      * @param   mixed   $user   Either an integer containing the user ID or a string containing the username.
  258.      *
  259.      * @return  array   The decoded JSON response or an empty array if the user is not invited.
  260.      *
  261.      * @since   13.1
  262.      */
  263.     public function isAttending($event$user)
  264.     {
  265.         return $this->getConnection($event'attending/' $user);
  266.     }
  267.  
  268.     /**
  269.      * Method to set the current user as attending. Requires authentication and rsvp_event permission.
  270.      *
  271.      * @param   string  $event  The event id.
  272.      *
  273.      * @return  boolean   Returns true if successful, and false otherwise.
  274.      *
  275.      * @since   13.1
  276.      */
  277.     public function createAttending($event)
  278.     {
  279.         return $this->createConnection($event'attending');
  280.     }
  281.  
  282.     /**
  283.      * Method to get the list of maybe attending users. Requires authentication and user_events or friends_events permission.
  284.      *
  285.      * @param   string   $event   The event id.
  286.      * @param   integer  $limit   The number of objects per page.
  287.      * @param   integer  $offset  The object's number on the page.
  288.      *
  289.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  290.      *
  291.      * @since   13.1
  292.      */
  293.     public function getMaybe($event$limit 0$offset 0)
  294.     {
  295.         return $this->getConnection($event'maybe'''$limit$offset);
  296.     }
  297.  
  298.     /**
  299.      * Method to check if a user is maybe attending an event. Requires authentication and user_events or friends_events permission.
  300.      *
  301.      * @param   string  $event  The event id.
  302.      * @param   mixed   $user   Either an integer containing the user ID or a string containing the username.
  303.      *
  304.      * @return  array   The decoded JSON response or an empty array if the user is not invited.
  305.      *
  306.      * @since   13.1
  307.      */
  308.     public function isMaybe($event$user)
  309.     {
  310.         return $this->getConnection($event'maybe/' $user);
  311.     }
  312.  
  313.     /**
  314.      * Method to set the current user as maybe attending. Requires authentication and rscp_event permission.
  315.      *
  316.      * @param   string  $event  The event id.
  317.      *
  318.      * @return  boolean   Returns true if successful, and false otherwise.
  319.      *
  320.      * @since   13.1
  321.      */
  322.     public function createMaybe($event)
  323.     {
  324.         return $this->createConnection($event'maybe');
  325.     }
  326.  
  327.     /**
  328.      * Method to get the list of users which declined the event. Requires authentication and user_events or friends_events permission.
  329.      *
  330.      * @param   string   $event   The event id.
  331.      * @param   integer  $limit   The number of objects per page.
  332.      * @param   integer  $offset  The object's number on the page.
  333.      *
  334.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  335.      *
  336.      * @since   13.1
  337.      */
  338.     public function getDeclined($event$limit 0$offset 0)
  339.     {
  340.         return $this->getConnection($event'declined'''$limit$offset);
  341.     }
  342.  
  343.     /**
  344.      * Method to check if a user responded 'no' to the event. Requires authentication and user_events or friends_events permission.
  345.      *
  346.      * @param   string  $event  The event id.
  347.      * @param   mixed   $user   Either an integer containing the user ID or a string containing the username.
  348.      *
  349.      * @return  array   The decoded JSON response or an empty array if the user is not invited.
  350.      *
  351.      * @since   13.1
  352.      */
  353.     public function isDeclined($event$user)
  354.     {
  355.         return $this->getConnection($event'declined/' $user);
  356.     }
  357.  
  358.     /**
  359.      * Method to set the current user as declined. Requires authentication and rscp_event permission.
  360.      *
  361.      * @param   string  $event  The event id.
  362.      *
  363.      * @return  boolean   Returns true if successful, and false otherwise.
  364.      *
  365.      * @since   13.1
  366.      */
  367.     public function createDeclined($event)
  368.     {
  369.         return $this->createConnection($event'declined');
  370.     }
  371.  
  372.     /**
  373.      * Method to get the list of users which have not replied to the event. Requires authentication and user_events or friends_events permission.
  374.      *
  375.      * @param   string   $event   The event id.
  376.      * @param   integer  $limit   The number of objects per page.
  377.      * @param   integer  $offset  The object's number on the page.
  378.      *
  379.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  380.      *
  381.      * @since   13.1
  382.      */
  383.     public function getNoreply($event$limit 0$offset 0)
  384.     {
  385.         return $this->getConnection($event'noreply'''$limit$offset);
  386.     }
  387.  
  388.     /**
  389.      * Method to check if a user has not replied to the event. Requires authentication and user_events or friends_events permission.
  390.      *
  391.      * @param   string  $event  The event id.
  392.      * @param   mixed   $user   Either an integer containing the user ID or a string containing the username.
  393.      *
  394.      * @return  array   The decoded JSON response or an empty array if the user is not invited.
  395.      *
  396.      * @since   13.1
  397.      */
  398.     public function isNoreply($event$user)
  399.     {
  400.         return $this->getConnection($event'noreply/' $user);
  401.     }
  402.  
  403.     /**
  404.      * Method to get the event's profile picture. Requires authentication and user_events or friends_events permission.
  405.      *
  406.      * @param   string   $event     The event id.
  407.      * @param   boolean  $redirect  If false this will return the URL of the picture without a 302 redirect.
  408.      * @param   string   $type      To request a different photo use square | small | normal | large.
  409.      *
  410.      * @return  string   The URL to the event's profile picture.
  411.      *
  412.      * @since   13.1
  413.      */
  414.     public function getPicture($event$redirect true$type null)
  415.     {
  416.         $extra_fields '';
  417.  
  418.         if ($redirect == false)
  419.         {
  420.             $extra_fields '?redirect=false';
  421.         }
  422.  
  423.         if ($type)
  424.         {
  425.             $extra_fields .= (strpos($extra_fields'?'=== false'?type=' $type '&type=' $type;
  426.         }
  427.  
  428.         return $this->getConnection($event'picture'$extra_fields);
  429.     }
  430.  
  431.     /**
  432.      * Method to get photos published on event's wall. Requires authentication.
  433.      *
  434.      * @param   string   $event   The event id.
  435.      * @param   integer  $limit   The number of objects per page.
  436.      * @param   integer  $offset  The object's number on the page.
  437.      * @param   string   $until   A unix timestamp or any date accepted by strtotime.
  438.      * @param   string   $since   A unix timestamp or any date accepted by strtotime.
  439.      *
  440.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  441.      *
  442.      * @since   13.1
  443.      */
  444.     public function getPhotos($event$limit 0$offset 0$until null$since null)
  445.     {
  446.         return $this->getConnection($event'photos'''$limit$offset$until$since);
  447.     }
  448.  
  449.     /**
  450.      * Method to post a photo on event's wall. Requires authentication and publish_stream permission.
  451.      *
  452.      * @param   string  $event    The event id.
  453.      * @param   string  $source   Path to photo.
  454.      * @param   string  $message  Photo description.
  455.      *
  456.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  457.      *
  458.      * @since   13.1
  459.      */
  460.     public function createPhoto($event$source$message null)
  461.     {
  462.         // Set POST request parameters.
  463.         $data array();
  464.         $data[basename($source)'@' realpath($source);
  465.  
  466.         if ($message)
  467.         {
  468.             $data['message'$message;
  469.         }
  470.  
  471.         return $this->createConnection($event'photos'$dataarray('Content-Type' => 'multipart/form-data'));
  472.     }
  473.  
  474.     /**
  475.      * Method to get videos published on event's wall. Requires authentication.
  476.      *
  477.      * @param   string   $event   The event id.
  478.      * @param   integer  $limit   The number of objects per page.
  479.      * @param   integer  $offset  The object's number on the page.
  480.      * @param   string   $until   A unix timestamp or any date accepted by strtotime.
  481.      * @param   string   $since   A unix timestamp or any date accepted by strtotime.
  482.      *
  483.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  484.      *
  485.      * @since   13.1
  486.      */
  487.     public function getVideos($event$limit 0$offset 0$until null$since null)
  488.     {
  489.         return $this->getConnection($event'videos'''$limit$offset$until$since);
  490.     }
  491.  
  492.     /**
  493.      * Method to post a video on event's wall. Requires authentication and publish_stream permission.
  494.      *
  495.      * @param   string  $event        The event id.
  496.      * @param   string  $source       Path to photo.
  497.      * @param   string  $title        Video title.
  498.      * @param   string  $description  Video description.
  499.      *
  500.      * @return  mixed   The decoded JSON response or false if the client is not authenticated.
  501.      *
  502.      * @since   13.1
  503.      */
  504.     public function createVideo($event$source$title null$description null)
  505.     {
  506.         // Set POST request parameters.
  507.         $data array();
  508.         $data[basename($source)'@' realpath($source);
  509.  
  510.         if ($title)
  511.         {
  512.             $data['title'$title;
  513.         }
  514.  
  515.         if ($description)
  516.         {
  517.             $data['description'$description;
  518.         }
  519.  
  520.         return $this->createConnection($event'videos'$dataarray('Content-Type' => 'multipart/form-data'));
  521.     }
  522. }

Documentation generated on Tue, 19 Nov 2013 15:02:40 +0100 by phpDocumentor 1.4.3