• Resolved jobme

    (@jobme)


    Hi Mike,

    Here is a huge issue I’m trying to figure out the last 2 days with no success.
    I have the jobify theme which puts the jobs on pins on google maps.
    Well this thing simply stopped working. Originally i thought it had something to do with the theme or with a plugin or something. But I’m quite sure it’s not.

    The case: 2 (the oldest ones) job ads do appear on the map but all the others not. So I clicked on edit (from WP – not from the manager) one such job and another that does not appear. What i discovered is that the ones that do appear have several custom fields like Geolocated (1), geolocation_city etc while the ones that do not appear do not have any custom fields filled in.

    Are there any ideas on that??

    Best regards and thanks in advance.
    Jim

    https://www.ads-software.com/plugins/wp-job-manager/

Viewing 15 replies - 16 through 30 (of 41 total)
  • Plugin Author Mike Jolley

    (@mikejolley)

    I don’t know if its the case here, but I read somewhere:

    Google also notes in their Web API Strategies document that you can be locked out from their service, meaning your IP address can be permanently banned from doing any geocoding.

    it also suggests that once the limit is reached, no further requests are attempted for 24hours.

    I’m going to ask that you contact the author of the other geocoding plugin and see if they use client geocoding or server (like my code does). Client won’t affect the server limit and would be better for the search suggestions.

    Hi Mike,

    I’m getting the same issue :

    array(5) { ["headers"]=> array(12) { ["content-type"]=> string(31) "application/json; charset=UTF-8" ["date"]=> string(29) "Mon, 08 Sep 2014 20:09:21 GMT" ["pragma"]=> string(8) "no-cache" ["expires"]=> string(29) "Fri, 01 Jan 1990 00:00:00 GMT" ["cache-control"]=> string(25) "no-cache, must-revalidate" ["vary"]=> string(15) "Accept-Language" ["access-control-allow-origin"]=> string(1) "*" ["server"]=> string(4) "mafe" ["x-xss-protection"]=> string(13) "1; mode=block" ["x-frame-options"]=> string(10) "SAMEORIGIN" ["alternate-protocol"]=> string(7) "80:quic" ["connection"]=> string(5) "close" } ["body"]=> string(137) "{ "error_message" : "You have exceeded your daily request quota for this API.", "results" : [], "status" : "OVER_QUERY_LIMIT" } " ["response"]=> array(2) { ["code"]=> int(200) ["message"]=> string(2) "OK" } ["cookies"]=> array(0) { } ["filename"]=> NULL }

    This is on a brand new install, with a new web hosting platform I’m trying out. There are only three jobs created. I did have Geojobmanager installed when I created the jobs, which I’ve now deactivated. I noticed jobs weren’t being geolocated which led me to this post.

    Any idea why this might be happening?

    Thanks,

    James

    Plugin Author Mike Jolley

    (@mikejolley)

    The common denominator is geojobmanager – I’m not 100% sure tbh. @jobme, did the author reply?

    https://stackoverflow.com/questions/3529746/over-query-limit-while-using-google-maps suggests there are also limits per second.

    Thread Starter jobme

    (@jobme)

    Hi guys, I didn’t even bother to contact them – both their plugins are not working for me and just deleted them. but the problem did not resolve. I still get the exceeded daily quota but I cannot understand why.

    The last thing I assume is that there is another site on my server (mt’s grid) that exceeds the limit all the time. But to be honest with you I cannot accept it as a valid cause – I bet all demos of wp job manager in various themes are on shared servers but work.

    Whoever finds a solution to this I would be more than happy to know it myself.

    Hi Mike, Jobme.

    Some Googling around the subject with the same error code suggests that being on a cloud hosting platform and sharing an IP address means you also share the API calls. (as jobm suggests with MT.)

    I logged a ticket with TSOhost asking if they think this is the case and they responded :

    Hi James,

    Yes – this will be due to you sharing api calls

    Can you authenticate and therefore remove the limits for the requests you make?

    Kind Regards,

    Seb

    Mike, just to clarify you’re using client side lookups aren’t you? I know Google’s API docs say you don’t run into the server limit, but do you think shared Cloud-based hosting could be the issue?

    As I said, the same install base of WP and plugins works on my local dev server and Heart Internet. I will do a fresh install on a new hosting package without the geojobmanager plugin to be sure.

    Unfortunately getting a Google Maps for Business API key isn’t an option for this project. I’m doing a freebie for a charity that matches people with disabilities with local carers looking for work!

    I’ll post back here with my findings re: fresh install.

    OK, I haven;t done a fresh install but I have been in contact with my host, TSOhost. We identified that an API key needs to be set because the API call limit was being hit by the aggregated number of calls coming from my cloud-based server.

    I created and activated an API key and amended your test script you posted to @jobme. I know get a successful lookup:

    array(5) { ["headers"]=> array(12) { ["content-type"]=> string(31) "application/json; charset=UTF-8" ["date"]=> string(29) "Tue, 09 Sep 2014 13:35:54 GMT" ["pragma"]=> string(8) "no-cache" ["expires"]=> string(29) "Fri, 01 Jan 1990 00:00:00 GMT" ["cache-control"]=> string(25) "no-cache, must-revalidate" ["vary"]=> string(15) "Accept-Language" ["access-control-allow-origin"]=> string(1) "*" ["server"]=> string(4) "mafe" ["x-xss-protection"]=> string(13) "1; mode=block" ["x-frame-options"]=> string(10) "SAMEORIGIN" ["alternate-protocol"]=> string(8) "443:quic" ["connection"]=> string(5) "close" } ["body"]=> string(111) "{ "error_message" : "The provided API key is expired.", "results" : [], "status" : "REQUEST_DENIED" } " ["response"]=> array(2) { ["code"]=> int(200) ["message"]=> string(2) "OK" } ["cookies"]=> array(0) { } ["filename"]=> NULL } array(5) { ["headers"]=> array(11) { ["content-type"]=> string(31) "application/json; charset=UTF-8" ["date"]=> string(29) "Tue, 09 Sep 2014 13:35:54 GMT" ["expires"]=> string(29) "Wed, 10 Sep 2014 13:35:54 GMT" ["cache-control"]=> string(21) "public, max-age=86400" ["vary"]=> string(15) "Accept-Language" ["access-control-allow-origin"]=> string(1) "*" ["server"]=> string(4) "mafe" ["x-xss-protection"]=> string(13) "1; mode=block" ["x-frame-options"]=> string(10) "SAMEORIGIN" ["alternate-protocol"]=> string(8) "443:quic" ["connection"]=> string(5) "close" } ["body"]=> string(1340) "{ "results" : [ { "address_components" : [ { "long_name" : "California", "short_name" : "CA", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "California, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 42.0095169, "lng" : -114.131211 }, "southwest" : { "lat" : 32.5342321, "lng" : -124.4096196 } }, "location" : { "lat" : 36.778261, "lng" : -119.4179324 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 42.0095169, "lng" : -114.131211 }, "southwest" : { "lat" : 32.5342321, "lng" : -124.4096196 } } }, "types" : [ "administrative_area_level_1", "political" ] } ], "status" : "OK" } " ["response"]=> array(2) { ["code"]=> int(200) ["message"]=> string(2) "OK" } ["cookies"]=> array(0) { } ["filename"]=> NULL }

    So now I was wondering if I could modify your plugin file to test if this fixes my problem. (Not a good solution I know but just to test!) Could you help me format the string, since I’ve tried to make the change and new jobs and old jobs re-saved still aren’t geolocating.

    I’ve changed the code in class-wp-job-manager-geocode.php starting at line 122 to add my API key before the sensor variable.

    if ( false === $geocoded_address || empty( $geocoded_address->results[0] ) ) {
    				$result = wp_remote_get(
    					apply_filters( 'job_manager_geolocation_endpoint', "https://maps.googleapis.com/maps/api/geocode/json?address=" . $raw_address . "&key=AIzaSy+++API KEY+++SYPycYk&sensor=true&region=" . apply_filters( 'job_manager_geolocation_region_cctld', '', $raw_address ), $raw_address ),
    					array(
    						'timeout'     => 5,
    					    'redirection' => 1,
    					    'httpversion' => '1.1',
    					    'user-agent'  => 'WordPress/WP-Job-Manager-' . JOB_MANAGER_VERSION . '; ' . get_bloginfo( 'url' ),
    					    'sslverify'   => false
    
    				    )
    				);

    As I say, this still isn’t geolocating jobs. How would you format the string?

    OK, got it sussed! I modified the class-wp-job-manager-geocode.php line 123-132 to read:

    $result = wp_remote_get(
    					"https://maps.googleapis.com/maps/api/geocode/json?address=" . $raw_address . "&key=+++APIKEY+++&sensor=true",
    					array(
    						'timeout'     => 5,
    					    'redirection' => 1,
    					    'httpversion' => '1.1',
    					    'user-agent'  => 'WordPress/WP-Job-Manager-' . JOB_MANAGER_VERSION . '; ' . get_bloginfo( 'url' ),
    					    'sslverify'   => false,
    								    )
    				);

    Obviously substituting my API key for the +++APIKEY+++ placeholder above. It now works and is Geocoding my jobs.

    Mike, I appreciate this is a free plugin, but is there any chance in a future release that there could be a space in the Dashboard to enter an API key? I’m running a simple job board for a disabled charity so I can re-do this mod after an update, but it would be useful.

    Anyway, hope this solution helps someone else!

    @jobme, you’ll need to go to https://code.google.com/apis/console/ and create a server API key for the Geocoding API. Get the IP address for your server from MediaTemple and use that as the referer IP. Then throw the switch for Geocoding API to “on” in the console once you’ve created the key to activate it.

    After that you can follow the steps above to add the API variable to the geocode query string.

    Plugin Author Mike Jolley

    (@mikejolley)

    Use the following code in your theme’s functions.php file:

    add_filter( 'job_manager_geolocation_endpoint', 'add_geolocation_key_to_endpoint' );
    
    function add_geolocation_key_to_endpoint( $endpoint ) {
    $endpoint = add_query_arg( 'key', 'YOURKEYHERE', $endpoint );
    return $endpoint;
    }

    That will append your key to the geolocation URL in job manager 1.14. If this works for everyone affected I’ll create some documentation on the subject and possibly add a core option as well.

    Thanks!

    Thanks Mike, I really appreciate you taking the time to do this. It always amazes me the quality of work that goes into free WordPress plugins!

    Cheers,

    James

    Thread Starter jobme

    (@jobme)

    guys, I admire your work. Let me test it myself and I’ll update you. Hopefully I’ll be successful too!

    Thread Starter jobme

    (@jobme)

    Ok, did the steps bluebananaconsulting said regarding the api and used only the second code you mention. What happened? it geolocated all previous ads but not a new one! strange, right?

    Thread Starter jobme

    (@jobme)

    but at the same time, according to google I have not used a single request out of the 2500.. Any idea?

    Thread Starter jobme

    (@jobme)

    funniest fact: In dashboard, if I click on the location it sends me to google maps exactly at the spot! but it doesn’t geocode…

    Interesting. I’m finding the code geolocates all new requests but not ones that I’d previously checked when the system wasn’t working!

    I tried to geolocate Cromer in Norfolk and it comes back with California! All new addresses are Geolocating so I wonder if there is some sort of error caused by cacheing. I’m going to have a play tomorrow. I’ll post my findings!

    Thread Starter jobme

    (@jobme)

    I suspected W3 total cache too. Keep us updated with as much info as possible! Thanks

Viewing 15 replies - 16 through 30 (of 41 total)
  • The topic ‘Huge issue with Geolocation’ is closed to new replies.