[Plugin: LinkedIn hResume] Was working fine and then it broke today
-
This plugin has been working fine for weeks and then this afternoon it just broke. Looks like it’s not just me either as other resumes uing this are having the same “Communication error”. Can anyone shed any light?
-
Same here. I’m getting the “Communication Error There was an error retrieving your public LinkedIn profile.”
Mine was working great for upwards of a year and then today I get the error above. Please help!
Same here, for all connected clients…
No response, I’m reporting this one broken.
I think it must be something LinkedIn have changed their end. I’ve just been trying out a few others the same as this plugin and none of them work correctly. The only one I can find that does work is the LinkedIn SC plugin so maybe give that one a go. https://www.ads-software.com/extend/plugins/linkedin-sc/
You can add all your own custom mark-up so it’s possible to make it the same as what you were using for the broken plugin.Just been trying out the LinkedIn SC plugin a bit more. Unfortuantely it doesn’t output as much of your resume as hResume does. Also it’s still actually broken a in a few places. Check out the end of this thread:
LinkedIn changed the HTML being used to display the profile, so obviously, the rules that were being used by the plugin to parse a public profile do not apply anymore…
. Hopefully not too big a job for the plugin developers. I’d love to have the hResume working again as it seems to be the most comprehensive.
Thanks, allycol. And I agree with your last comment – hResume is more comprehensive and easier to setup. I installed LinkedIn SC and spent ~15 minutes getting it setup. Lots of manual monkeying around to get less results than what you get with hResume.
I was really hoping Brad would’ve at least replied to this thread, but it looks like hResume might be dead. ??
I have managed to get the plugin partially working by adding some HTML classes. The result is way more compact than the original, but at least this solution buys us some time; replace all occurrences of
<div class="hresume">
with<div id="content" class="resume hresume">
I’m more of a hacker than a coder, but I presume if the callbacks to description, callbacks, honors and notes get fixed, then the resultpage will more closely match the original results.
Still puzzled by the lack of feedback from the original developer. And a bit surprised that this plugin basically is a scraper.
Thanks Nowton for this “tip”, it fixed partially the hole. Hopefully the dev will be back on this plugin.
Ok so I think that I may have fixed it. It was mainly the sections that were renamed specifically by linkedin.
https://thomasnorberg.com/resume/
1st (Line 132):
replace<div class="hresume">
with<div id="content" class="resume hresume">
2st (Line 138):
replace<body class="public-profile">
with<body class="en member v2 public-profile" id="pagekey-nprofile-public-success">
3rd (Line 151):
replace<div class="hresume">
with<div id="content" class="resume hresume">
4th (Line 152):
replace<div id="contact-settings">
with<div class="section" id="profile-contact" style="display:block">
Although this might not be the best way to implement a plugin based off of HTML scraping because you are at the mercy of the site developing the software or displaying the information. We might need to look into something a little more effective (using API from LinkedIN perhaps). Was trying to understand the API a little better but was running into some dead ends and would like to have more time to look into it but at this time do not. Any takers might need to contact the developer about this and maybe come up with something a little more full proof.
Corrected Code from “linkedin_hresume.php”:
<?php /* Plugin Name: LinkedIn hResume Plugin URI: https://www.ads-software.com/extend/plugins/linkedin-hresume/ Description: LinkedIn hResume grabs the Microformated hResume block from your LinkedIn public profile page allowing you to add it to any page and apply your own styles to it. Author: Brad Touesnard Author URI: https://bradt.ca/ Version: 0.3.2 */ // Your public LinkedIn profile URL $linkedin_url = 'https://www.linkedin.com/in/bradt'; $lnhr_enable_cache = false; /* INSTALLATION * Please see the readme.txt file for installation details. */ function lnhr_shortcode($atts) { global $linkedin_url, $lnhr_enable_cache; extract(shortcode_atts(array( 'url' => $linkedin_url, 'caching' => $lnhr_enable_cache, ), $atts)); $caching = lnhr_is_caching($caching); $lnhr_enable_cache = $caching; $linkedin_url = $url; return lnhr_get_hresume($url, $caching); } /* Backward compatibility: Support for comment code */ function lnhr_callback($content) { global $linkedin_url, $lnhr_enable_cache; if(!preg_match('@(?:<p>)?(?:<|<)!(?:--|–)LinkedIn hResume(.*)(?:--|–)(?:>|>)(?:</p>)?@', $content, $matches)) { return $content; } if ($matches[1]) { list($url, $cache) = split(',', $matches[1]); if ($url) { $linkedin_url = trim($url); } $lnhr_enable_cache = lnhr_is_caching($cache); } $hresume = lnhr_get_hresume($linkedin_url, $lnhr_enable_cache); return str_replace($matches[0], $hresume, $content); } // Developers: This function can be used in your WordPress templates function lnhr_get_hresume($url, $caching = false) { $hresume = ''; if ($caching) { $cache = get_option('lnhr_cache'); if ($cache !== false) { list($cache_url, $expiry, $data) = $cache; if ($url == $cache_url && $expiry > time()) { $hresume = $data; } } } if (!$hresume) { $hresume = lnhr_get_linkedin_page($url); lnhr_error_check($hresume, $url); $hresume = lnhr_stripout_hresume($hresume); $hresume = balanceTags($hresume, true); if ($caching) { update_option('lnhr_cache', array($url, time()+21600, $hresume)); } } return $hresume; } function lnhr_is_caching($value) { return (in_array($value, explode(',', 'on,true,1'))); } function lnhr_get_linkedin_page($url) { // Request the LinkedIn page if(function_exists('wp_remote_get')) { $parsed_url = @parse_url( $url ); if ( !$parsed_url || !is_array( $parsed_url ) ) $data = "Invalid LinkedIn URL."; $options = array(); $options['timeout'] = 100; $response = wp_remote_get( $url, $options ); if ( is_wp_error( $response ) ) return false; $data = $response['body']; } else { $data = "Sorry, your version of WordPress does not support the 'wp_remote_fopen' function. Please upgrade your version of WordPress."; } return $data; } function lnhr_format_block($matches) { $desc = $matches[2]; $desc = strip_tags($desc); $desc = trim($desc); $desc = Markdown($desc); // Make links clickable $desc = preg_replace('@(http:\/\/[^\s<>]+)@i', '<a href="$1">$1</a>', $desc); $desc = wpautop($desc); return '<div class="' . $matches[1] . '">' . $desc . '</div>'; } function lnhr_error_check($content, $url) { //echo $content; $pos = strpos($content, '<div id="content" class="resume hresume">'); if ($pos === false) { $pos = strpos($content, 'Profile Not Found'); if ($pos !== false) { wp_die('<h1>Profile Not Found</h1><p>The profile <a href="' . $url . '">' . $url . '</a> could not be found.</p>'); } elseif (preg_match('@<body class="en member v2 public-profile" id="pagekey-nprofile-public-success"> (.*?)</body>@s', $content, $matches)) { wp_die($matches[1]); } else { wp_die('<h1>Communication Error</h1><p>There was an error retrieving your LinkedIn public profile.</p>'); } } } function lnhr_stripout_hresume($content) { // Just grab the hResume part minus some extra LinkedIn junk // Kind of lazy, but maybe do some parsing in another version $hresume = strstr($content, '<div id="content" class="resume hresume">'); $pos = strpos($hresume, '<div class="section" id="profile-contact" style="display:block">'); if ($pos !== false) { $hresume = substr($hresume, 0, $pos); $hresume .= '</div>'; } // Remove any Javascript $hresume = preg_replace('/<[ \n\r]*script[^>]*>.*<[ \n\r]*\/script[^>]*>/si', '', $hresume); // This is the path to markdown.php if ( !defined('AUTOMATTIC_README_MARKDOWN') ) define('AUTOMATTIC_README_MARKDOWN', dirname(__FILE__) . '/markdown.php'); if ( !function_exists('Markdown') ) require( AUTOMATTIC_README_MARKDOWN ); $hresume = preg_replace_callback('@<p class="(description)">(.*?)</p>@s', 'lnhr_format_block', $hresume); $hresume = preg_replace_callback('@<p class="(skills)">(.*?)</p>@s', 'lnhr_format_block', $hresume); $hresume = preg_replace_callback('@<p class="(honors)">(.*?)</p>@s', 'lnhr_format_block', $hresume); $hresume = preg_replace_callback('@<p class="(notes)">(.*?)</p>@s', 'lnhr_format_block', $hresume); // Make the links clickable for groups and companies $hresume = preg_replace_callback('@<a href="(/.*?)"@s', 'lnhr_format_link', $hresume, -1, $count); // Markup abbrevations INCOMPLETE $hresume = preg_replace('/([^a-zA-Z0-9])(CVS)([^a-zA-Z0-9])/', '$1<abbr title="Concurrent Versioning System">$2</abbr>$3', $hresume); // Convert LinkedIn tags to XHTML $hresume = preg_replace('/<\s*br\s*>/si', '<br />', $hresume); // Why does LinkedIn repeat your name so much on the same page? if (preg_match('@<span class="given-name">([^<]+)</span>@', $hresume, $matches)) { $name = $matches[1]; $matches = array(); if (preg_match('@<span class="family-name">([^<]+)</span>@', $hresume, $matches)) { $name = $name . ' ' . $matches[1]; $hresume = str_ireplace($name . '’s ', '', $hresume); } } return $hresume; } function lnhr_format_link($matches) { $linktext = $matches[1]; if (substr($linktext, 0, 1) == '/') { $linktext = 'https://www.linkedin.com' . $linktext; } return '<a href="' . $linktext . '"'; } add_filter('the_content', 'lnhr_callback', 50); add_shortcode('lnhr', 'lnhr_shortcode'); ?>
Nicely done! I implemented the changes and it works. Thanks, Tom!
Your welcome just trying to help out my fellow WordPresser’s
Tom
- The topic ‘[Plugin: LinkedIn hResume] Was working fine and then it broke today’ is closed to new replies.