Source for file jobs.php

Documentation is available at jobs.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Linkedin
  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.  * Linkedin API Jobs class for the Joomla Platform.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Linkedin
  17.  * @since       13.1
  18.  */
  19. {
  20.     /**
  21.      * Method to retrieve detailed information about a job.
  22.      *
  23.      * @param   integer  $id      The unique identifier for a job.
  24.      * @param   string   $fields  Request fields beyond the default ones.
  25.      *
  26.      * @return  array  The decoded JSON response
  27.      *
  28.      * @since   13.1
  29.      */
  30.     public function getJob($id$fields null)
  31.     {
  32.         $token $this->oauth->getToken();
  33.  
  34.         // Set parameters.
  35.         $parameters array(
  36.             'oauth_token' => $token['key']
  37.         );
  38.  
  39.         // Set the API base
  40.         $base '/v1/jobs/' $id;
  41.  
  42.         // Set request parameters.
  43.         $data['format''json';
  44.  
  45.         // Check if fields is specified.
  46.         if ($fields)
  47.         {
  48.             $base .= ':' $fields;
  49.         }
  50.  
  51.         // Build the request path.
  52.         $path $this->getOption('api.url'$base;
  53.  
  54.         // Send the request.
  55.         $response $this->oauth->oauthRequest($path'GET'$parameters$data);
  56.  
  57.         return json_decode($response->body);
  58.     }
  59.  
  60.     /**
  61.      * Method to get a list of bookmarked jobs for the current member.
  62.      *
  63.      * @param   string  $fields  Request fields beyond the default ones.
  64.      *
  65.      * @return  array  The decoded JSON response
  66.      *
  67.      * @since   13.1
  68.      */
  69.     public function getBookmarked($fields null)
  70.     {
  71.         $token $this->oauth->getToken();
  72.  
  73.         // Set parameters.
  74.         $parameters array(
  75.             'oauth_token' => $token['key']
  76.         );
  77.  
  78.         // Set the API base
  79.         $base '/v1/people/~/job-bookmarks';
  80.  
  81.         // Set request parameters.
  82.         $data['format''json';
  83.  
  84.         // Check if fields is specified.
  85.         if ($fields)
  86.         {
  87.             $base .= ':' $fields;
  88.         }
  89.  
  90.         // Build the request path.
  91.         $path $this->getOption('api.url'$base;
  92.  
  93.         // Send the request.
  94.         $response $this->oauth->oauthRequest($path'GET'$parameters$data);
  95.  
  96.         return json_decode($response->body);
  97.     }
  98.  
  99.     /**
  100.      * Method to bookmark a job to the current user's account.
  101.      *
  102.      * @param   integer  $id  The unique identifier for a job.
  103.      *
  104.      * @return  array  The decoded JSON response
  105.      *
  106.      * @since   13.1
  107.      */
  108.     public function bookmark($id)
  109.     {
  110.         $token $this->oauth->getToken();
  111.  
  112.         // Set parameters.
  113.         $parameters array(
  114.             'oauth_token' => $token['key']
  115.         );
  116.  
  117.         // Set the success response code.
  118.         $this->oauth->setOption('success_code'201);
  119.  
  120.         // Set the API base
  121.         $base '/v1/people/~/job-bookmarks';
  122.  
  123.         // Build xml.
  124.         $xml '<job-bookmark><job><id>' $id '</id></job></job-bookmark>';
  125.  
  126.         // Build the request path.
  127.         $path $this->getOption('api.url'$base;
  128.  
  129.         $header['Content-Type''text/xml';
  130.  
  131.         // Send the request.
  132.         $response $this->oauth->oauthRequest($path'POST'$parameters$xml$header);
  133.  
  134.         return $response;
  135.     }
  136.  
  137.     /**
  138.      * Method to delete a bookmark.
  139.      *
  140.      * @param   integer  $id  The unique identifier for a job.
  141.      *
  142.      * @return  array  The decoded JSON response
  143.      *
  144.      * @since   13.1
  145.      */
  146.     public function deleteBookmark($id)
  147.     {
  148.         $token $this->oauth->getToken();
  149.  
  150.         // Set parameters.
  151.         $parameters array(
  152.             'oauth_token' => $token['key']
  153.         );
  154.  
  155.         // Set the success response code.
  156.         $this->oauth->setOption('success_code'204);
  157.  
  158.         // Set the API base
  159.         $base '/v1/people/~/job-bookmarks/' $id;
  160.  
  161.         // Build the request path.
  162.         $path $this->getOption('api.url'$base;
  163.  
  164.         // Send the request.
  165.         $response $this->oauth->oauthRequest($path'DELETE'$parameters);
  166.  
  167.         return $response;
  168.     }
  169.  
  170.     /**
  171.      * Method to retrieve job suggestions for the current user.
  172.      *
  173.      * @param   string   $fields  Request fields beyond the default ones.
  174.      * @param   integer  $start   Starting location within the result set for paginated returns.
  175.      * @param   integer  $count   The number of results returned.
  176.      *
  177.      * @return  array  The decoded JSON response
  178.      *
  179.      * @since   13.1
  180.      */
  181.     public function getSuggested($fields null$start 0$count 0)
  182.     {
  183.         $token $this->oauth->getToken();
  184.  
  185.         // Set parameters.
  186.         $parameters array(
  187.             'oauth_token' => $token['key']
  188.         );
  189.  
  190.         // Set the API base
  191.         $base '/v1/people/~/suggestions/job-suggestions';
  192.  
  193.         $data['format''json';
  194.  
  195.         // Check if fields is specified.
  196.         if ($fields)
  197.         {
  198.             $base .= ':' $fields;
  199.         }
  200.  
  201.         // Check if start is specified.
  202.         if ($start 0)
  203.         {
  204.             $data['start'$start;
  205.         }
  206.  
  207.         // Check if count is specified.
  208.         if ($count 0)
  209.         {
  210.             $data['count'$count;
  211.         }
  212.  
  213.         // Build the request path.
  214.         $path $this->getOption('api.url'$base;
  215.  
  216.         // Send the request.
  217.         $response $this->oauth->oauthRequest($path'GET'$parameters$data);
  218.  
  219.         return json_decode($response->body);
  220.     }
  221.  
  222.     /**
  223.      * Method to search across LinkedIn's job postings.
  224.      *
  225.      * @param   string   $fields        Request fields beyond the default ones.
  226.      * @param   string   $keywords      Members who have all the keywords anywhere in their profile.
  227.      * @param   string   $company_name  Jobs with a matching company name.
  228.      * @param   string   $job_title     Matches jobs with the same job title.
  229.      * @param   string   $country_code  Matches members with a location in a specific country. Values are defined in by ISO 3166 standard.
  230.      *                                      Country codes must be in all lower case.
  231.      * @param   integer  $postal_code   Matches members centered around a Postal Code. Must be combined with the country-code parameter.
  232.      *                                      Not supported for all countries.
  233.      * @param   integer  $distance      Matches members within a distance from a central point. This is measured in miles.
  234.      * @param   string   $facets        Facet buckets to return, e.g. location.
  235.      * @param   array    $facet         Array of facet values to search over. Contains values for company, date-posted, location, job-function,
  236.      *                                      industry, and salary, in exactly this order, null must be specified for an element if no value.
  237.      * @param   integer  $start         Starting location within the result set for paginated returns.
  238.      * @param   integer  $count         The number of results returned.
  239.      * @param   string   $sort          Controls the search result order. There are four options: R (relationship), DA (date-posted-asc),
  240.      *                                      DD (date-posted-desc).
  241.      *
  242.      * @return  array  The decoded JSON response
  243.      *
  244.      * @since   13.1
  245.      */
  246.     public function search($fields null$keywords null$company_name null$job_title null$country_code null$postal_code null,
  247.         $distance null$facets null$facet null$start 0$count 0$sort null)
  248.     {
  249.         $token $this->oauth->getToken();
  250.  
  251.         // Set parameters.
  252.         $parameters array(
  253.             'oauth_token' => $token['key']
  254.         );
  255.  
  256.         // Set the API base
  257.         $base '/v1/job-search';
  258.  
  259.         $data['format''json';
  260.  
  261.         // Check if fields is specified.
  262.         if ($fields)
  263.         {
  264.             $base .= ':' $fields;
  265.         }
  266.  
  267.         // Check if keywords is specified.
  268.         if ($keywords)
  269.         {
  270.             $data['keywords'$keywords;
  271.         }
  272.  
  273.         // Check if company-name is specified.
  274.         if ($company_name)
  275.         {
  276.             $data['company-name'$company_name;
  277.         }
  278.  
  279.         // Check if job-title is specified.
  280.         if ($job_title)
  281.         {
  282.             $data['job-title'$job_title;
  283.         }
  284.  
  285.         // Check if country_code is specified.
  286.         if ($country_code)
  287.         {
  288.             $data['country-code'$country_code;
  289.         }
  290.  
  291.         // Check if postal_code is specified.
  292.         if ($postal_code)
  293.         {
  294.             $data['postal-code'$postal_code;
  295.         }
  296.  
  297.         // Check if distance is specified.
  298.         if ($distance)
  299.         {
  300.             $data['distance'$distance;
  301.         }
  302.  
  303.         // Check if facets is specified.
  304.         if ($facets)
  305.         {
  306.             $data['facets'$facets;
  307.         }
  308.  
  309.         // Check if facet is specified.
  310.         if ($facet)
  311.         {
  312.             $data['facet'array();
  313.             for ($i 0$i count($facet)$i++)
  314.             {
  315.                 if ($facet[$i])
  316.                 {
  317.                     if ($i == 0)
  318.                     {
  319.                         $data['facet']['company,' $this->oauth->safeEncode($facet[$i]);
  320.                     }
  321.                     if ($i == 1)
  322.                     {
  323.                         $data['facet']['date-posted,' $facet[$i];
  324.                     }
  325.                     if ($i == 2)
  326.                     {
  327.                         $data['facet']['location,' $facet[$i];
  328.                     }
  329.                     if ($i == 3)
  330.                     {
  331.                         $data['facet']['job-function,' $this->oauth->safeEncode($facet[$i]);
  332.                     }
  333.                     if ($i == 4)
  334.                     {
  335.                         $data['facet']['industry,' $facet[$i];
  336.                     }
  337.                     if ($i == 5)
  338.                     {
  339.                         $data['facet']['salary,' $facet[$i];
  340.                     }
  341.                 }
  342.             }
  343.         }
  344.  
  345.         // Check if start is specified.
  346.         if ($start 0)
  347.         {
  348.             $data['start'$start;
  349.         }
  350.  
  351.         // Check if count is specified.
  352.         if ($count 0)
  353.         {
  354.             $data['count'$count;
  355.         }
  356.  
  357.         // Check if sort is specified.
  358.         if ($sort)
  359.         {
  360.             $data['sort'$sort;
  361.         }
  362.  
  363.         // Build the request path.
  364.         $path $this->getOption('api.url'$base;
  365.  
  366.         // Send the request.
  367.         $response $this->oauth->oauthRequest($path'GET'$parameters$data);
  368.  
  369.         return json_decode($response->body);
  370.     }
  371. }

Documentation generated on Tue, 19 Nov 2013 15:06:05 +0100 by phpDocumentor 1.4.3