Wordpress template to search and get job ids using api

Following Wordpress plugin shortcode is used to insert job ids from indeed.com. This template is deisgned based on indeed.com job search api. Please signup for api key before using this template.
Below code will only create post with job id in the format of shortcode [insertjobsindeed jobkey='".$jobkey."'] which needs to be used along with another plugin referred in another forum post forum.indiacitys.com/index.php?p=/discussion/51/wordpress-php-page-template-code-to-search-and-insert-job-details-from-indeed-com?new=1
So that user click on post with jobid then it will run another plugin to get job details. Please remember that ip address needs to be passed
<?php /* Plugin Name: insertjobsindeed Description: Insert jobsindeed Version: 0.1 Author: http://forum.indiacitys.com */ function insertjobsindeed() { $loctax = 'Coimbatore'; $jstate = 'Tamil Nadu'; $ipaddr = $_SERVER['REMOTE_ADDR']; $useragent = $_SERVER['HTTP_USER_AGENT']; $useragent = urlencode($useragent); $eventurl = 'http://api.indeed.com/ads/apisearch?publisher=xxxxxxxxxxxxxxxxx&q=job&l='.$loctax.'&limit=50&co=in&userip='.$ipaddr.'&useragent='.$useragent.'&v=2'; $string = file_get_contents($eventurl); $jobs = new SimpleXMLElement($string); $events = $jobs->results->result; //$total_pages = $jobs->rq->tv; $cevents = count($events); if ($cevents > 0 ) { foreach ($events as $event) { $event_src = $event->url; $event_loc = $event->formattedLocation; $jobkey = $event->jobkey; $wordpress_post_title = $event->jobtitle; $wordpress_post_keywords = $event->jobtitle.",jobs,classifieds,jobs classifieds,".$loctax.",jobs in ".$loctax.",jobs in ".$jstate; $wordpress_post_content = "[insertjobsindeed jobkey='".$jobkey."']"; $wordpress_post_tagline = ' jobs available in '.$event->city.'.Browse and Apply for jobs.'.$event->jobtitle; $wordpress_map_location = $event->city.','.$event->state.',India'; $post_id = wp_insert_post( array( 'post_title' => $wordpress_post_title, 'post_content' => $wordpress_post_content, 'post_category' => array('2428'), 'post_type' => 'post', 'tags_input' => $wordpress_post_keywords, 'post_excerpt' => $wordpress_post_tagline, 'post_status' => 'publish', )); add_post_meta($post_id, 'map_location', $wordpress_map_location, true); } } } register_activation_hook( __FILE__, 'insertjobsindeed' ); ?>
Sign In or Register to comment.