function test_connecting() { $key = $_POST['key']; if ($key) { $api = $this->get_settings(); extract($api); $api_key = isset($api['api_key']) ? trim($api['api_key']) : ''; $secret_key = isset($api['secret_key']) ? trim($api['secret_key']) : ''; $token = isset($api['token']) ? trim($api['token']) : ''; $token_secret = isset($api['token_secret']) ? trim($api['token_secret']) : ''; $API_CONFIG = array('appKey' => $api_key, 'appSecret' => $secret_key, 'callbackUrl' => NULL); $TOKEN_CONFIG = array('oauth_token' => $token, 'oauth_token_secret' => $token_secret); $linkedin = new WP_LinkedIn_LinkedIn($API_CONFIG); $linkedin->setTokenAccess($TOKEN_CONFIG); $linkedin->setResponseFormat(WP_LinkedIn_LinkedIn::_RESPONSE_XML); $response = $linkedin->searchJobs('?keywords=quality&count=1'); if ($response['success'] === true) { echo 'Connected successfully. Now you can import linkedin jobs into your job board.'; } else { $err = simplexml_load_string($response['linkedin']); echo 'Erorr: ' . $err->message . '. Please check your LinkedIn API '; } } //echo json_encode($response); die; }
public function create_xml_custom($data) { $total = (array) $data->jobs['total']; $start = $data->jobs['start']; $count = (array) $data->jobs['count']; $jobs = $data->jobs->job; $html = ''; $xml = ''; if ($jobs) { $i = 0; foreach ($jobs as $item) { $jobid = $item->id; $api = $this->get_settings(); extract($api); $api_key = isset($api['api_key']) ? trim($api['api_key']) : ''; $secret_key = isset($api['secret_key']) ? trim($api['secret_key']) : ''; $API_CONFIG = array('appKey' => $api_key, 'appSecret' => $secret_key, 'callbackUrl' => NULL); $linkedin = new WP_LinkedIn_LinkedIn($API_CONFIG); $response = $linkedin->job((string) $jobid, ':(id,active,posting-date,company:(name),position:(title,location,job-functions,industries,job-type),skills-and-experience,description-snippet,description,salary,job-poster:(id,headline),site-job-url,location-description)'); if ($response['success'] === TRUE) { $job = simplexml_load_string($response['linkedin']); $job = (array) $job; $id = $job['id']; $url = $job['site-job-url']; $date = (array) $job['posting-date']; $year = $date['year']; $month = $date['month']; $day = $date['day']; $fulldate = $year . '-' . $month . '-' . $day; $locatoin = (array) $job['position']->location; $company = $job['company']->name; $content = $job['description']; $city = ''; $country = (array) $locatoin['country']; $title = $job['position']->title; $job_type = (array) $job['position']; $job_type = $job_type['job-type']->name; $state = ''; $i++; $list = $this->et_get_job_type(); $cats = $this->et_job_categories_option_list(); $html[] = '<tr> <td> <input type="hidden" name="import[' . $i . '][allow]" value="0"/> <input type="checkbox" class="allow" name="import[' . $i . '][allow]" value="1" checked="checked"/> <input type="hidden" name="import[' . $i . '][url]" value="' . $url . '"/> <input type="hidden" name="import[' . $i . '][date]" value="' . $fulldate . '"/> <input type="hidden" name="import[' . $i . '][formattedLocationFull]" value="' . $locatoin['name'] . '"/> <input type="hidden" name="import[' . $i . '][company]" value="' . $company . '"/> <input type="hidden" name="import[' . $i . '][jobkey]" value="' . $id . '"/> <div style="display:none;"><input type="hidden" name="import[' . $i . '][content]" value="' . $content . '"/></div> <input type="hidden" name="import[' . $i . '][city]" value="' . $city . '"/> <input type="hidden" name="import[' . $i . '][state]" value="' . $state . '"/> <input type="hidden" name="import[' . $i . '][country]" value="' . $country['code'] . '"/> <input type="hidden" name="import[' . $i . '][jobtitle]" value="' . $title . '"/> </td> <td class="jobtitle"> <a href="' . $url . '" target="_blank">' . $title . '</a> <div class="bubble-quote"> <span>@ ' . $company . '</span> <span class="icon" data-icon="@">' . $locatoin['name'] . '</span> <div class="triangle"></div> </div> </td> <td class="jobtitle">' . $job_type . '</td> <td> <div class="select-style et-button-select"> <select class="job_cat" name="import[' . $i . '][job_category]"> ' . $cats . ' </select> </div> </td> <td> <div class="select-style et-button-select"> <select class="job_type" name="import[' . $i . '][job_type]"> ' . $list . ' </select> </div> </td> </tr>'; } $xml['total'] = $total['0']; $xml['count'] = isset($count['0']) ? $count['0'] : $i; $xml['jobs'] = array('job' => $html); } } else { $xml['total'] = 0; $xml['count'] = 0; $xml['jobs'] = array('job' => ''); } return $xml; }