It appears that the URL shortener is returning error messages when called too regularly. If you add a clause in
gde_get_short_url()to check whether body equals the error message value (I’m seeing this: Error: Rate limit exceeded – please wait 1 minute before shortening further URLs.). This value is ending up cached which in turn makes the document unloadable until plugin cache is purged.
On a completely unrelated note, I posted a while back mentioning wanting to find the number of pages in a given document. I’ve since found a simple way to do it just adding three lines into
gde_get_contents(). Inserting the following directly prior to
return $resultwill sets $pages to total pages in document.
$ptn = '/,numPages:(\d+),/'; preg_match( $ptn, $result, $match ); $pages = $match;
The only added overhead would be the cost of preg, which shouldn’t be much. Could also be further optimized by using
strpos()instead, if desired.
Obviously this isn’t useful on its own, but may have potential for improving plugin functioning. Even if it can’t directly be used for any plugin functions, just making this accessible to developers would be probably be useful (obviously in a cleaner way than this simple example).
All the best!
- The topic ‘gde_get_short_url() returning error message & numPages retrieval solution’ is closed to new replies.