• I am getting the following error each time Sermon Browser attempts to download a sermon’s associated associated bible verse:

    ERROR: The IP key is no longer supported. Please use your access key, the testing key ‘TEST’

    I am using the default ESV bible and, other than adding new sermons, there have been no changes to the page. This is apparently new, as it was working fine two weeks ago. The error appears on all sermons, not just the more recent ones.

    A search on the error yielded no results. Any help/suggestions/sympathy would be appreciated.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 16 through 30 (of 36 total)
  • A green horn here so forgive my ignorance, but exactly where are you editing this code? I am having trouble locating it. Thanks

    If you are using an editor like Dreamweaver or Notepad++ the topic of discussion would be on lines 413 through 419 in /wp-content/plugins/sermon-browser/sb-includes/frontend.php. Do a search for “ESV API key” and that should get you there.

    I haven’t played with it anymore. Just posted a notice about scripture not currently working until a site upgrade occurs – whenever I will get to that migration…

    @mtjarrett
    The difference between the 2 URLs is the esvapi.org one is the old deprecated V2 API. The api.esv.org URL is the new V3 supported API from Crossway. Documentation is here on the API and how to request a key for your application: https://api.esv.org/v3/docs/

    By setting up your own authorization key, you are ensuring that your site is the only one making up to 5K queries daily and you are not sharing that like with the old ‘test’ key.

    The API for both V2 and V3 is Rest. For the new V3 supported one, there are 2 Rest API output types: text or html, both delivered in JSON format. I use the html one on my church site since it comes preformatted with some tags to make the content more readable. It really is a matter of preference as to which you want to use.

    Thanks @klandis79.

    I would gladly pay you for your time if you could help me get this thing transferred to V3 with my new key. I’ve read the docs page you linked to several times and it assumes a knowledge that I simply don’t have.

    My old function looked like this:

    function get_esv_reading($scripture, $options) {	
    	$key = "test";
    	$passage = urlencode($scripture);
    	$url = "https://www.esvapi.org/v2/rest/passageQuery?key=".$key."&passage=".$passage."&".$options;
    	$ch = curl_init($url); 
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
      	$response = curl_exec($ch);
      	curl_close($ch);
      
    	return ("<span class=\"esv-scripture\">" . $response . "</span>");
    }

    @mtjarrett
    I couldn’t fully test this without knowing your plugin and trying my code change, but I think the following should work.

    The important piece here is you need to go to here and request an API token from Crossway by creating a login and application ID: https://api.esv.org/account/create-application/

    Once you have the 40 character long string, replace the ‘XXXXXXXX’ after the word Token in the authorization line below:

    function get_esv_reading($scripture, $options) {	
      $url = 'https://api.esv.org/v3/passage/html/?q='.urlencode($scripture).'&include-headings=false&include-footnotes=false';
    
      $curl = curl_init();
    
      curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "GET",
        CURLOPT_HTTPHEADER => array(
          "authorization: Token XXXXXXXX",
          "cache-control: no-cache"
        ),
      ));
    
      $response = curl_exec($curl);
      $err = curl_error($curl);
    
      curl_close($curl);
    
      $json = json_decode($response, true);
      $passage = $json["passages"][0];
      
    	return ("<span class=\"esv-scripture\">" . $passage . "</span>");
    }
    • This reply was modified 7 years, 1 month ago by klandis79.

    @klandis79 THANK YOU!

    This did it.

    As I said, I am happy to pay you for this time. You can let me know how to do so here or drop me a line at my website thetrinitymission.org.

    Thanks.

    @mtjarrett
    No need for payment. I’m glad I could help you out since I went through fixing this same thing on my church site last November.

    timwarner69

    (@timwarner69)

    @klandis79 I’m experiencing the same issues – would you mind just giving me the benefit of your expertise please?

    I’m using Sermon Browser on our church site & am working on a staging site at staging.thurnbychurch.com

    I’ve added the amended url & API key in fronted.php here:

    function sb_add_esv_text ($start, $end) {
    $esv_url = ‘https://api.esv.org/v3/passage/html/?q=f79c1e8a036f6bfe6f6677a916681ca40e5502ef&passage=&#8217;.rawurlencode(sb_tidy_reference ($start, $end)).’&include-headings=false&include-footnotes=false’;
    return sb_download_page ($esv_url);

    And added your new function from your previous post at the end of the function.php file, but am getting an error on the page of:

    {“detail”:”Authentication credentials were not provided.”}

    Any ideas what I’m doing wrong please?

    klandis79

    (@klandis79)

    @timwarner69 unfortunately, I use a different plugin that had the same issue as sermon browser, so without seeing the full set of code, I’ll do my best to take a stab at what I did see in your post that could be causing the problem. It looks like your $esv_url is not formatted properly. There should be nothing after q= in the first part of the string and it should continue with .rawurlencode… like this:

    $esv_url = ‘https://api.esv.org/v3/passage/html/?q=’.rawurlencode(sb_tidy_reference ($start, $end)).’&include-headings=false&include-footnotes=false’;

    Then, your sb_download_page function further down should be modified like this below inside the first if statement with ###VALUE-FROM-API.ESV.ORG-SETUP### replaced with your Crossway token from creating an account and application profile here: https://api.esv.org/

    if (function_exists('curl_init')) {
    $curl = curl_init();
    curl_setopt_array($curl, array(
    	CURLOPT_URL => $esv_url,
    	CURLOPT_RETURNTRANSFER => true,
    	CURLOPT_ENCODING => "",
    	CURLOPT_MAXREDIRS => 10,
    	CURLOPT_TIMEOUT => 30,
    	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    	CURLOPT_CUSTOMREQUEST => "GET",
    	CURLOPT_HTTPHEADER => array(
    		"authorization: Token ###VALUE-FROM-API.ESV.ORG-SETUP###",
    		"cache-control: no-cache"
    	),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    $json = json_decode($response, true);
    $contents = $json["passages"][0];
    	}
    	else...
    timwarner69

    (@timwarner69)

    @klandis79 thanks so much. It hasn’t quite worked though… & I’m sure it’s just me. This is the full sb_download_page function – would you mind just amending it to include your code in the correct place/format & I’ll just copy & paste it over the whole thing…? This is all a bit out of my comfort zone!

    function sb_download_page ($page_url) {
    if (function_exists(‘curl_init’)) {
    $curl = curl_init();
    curl_setopt ($curl, CURLOPT_URL, $page_url);
    curl_setopt ($curl, CURLOPT_TIMEOUT, 2);
    curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($curl, CURLOPT_HTTPHEADER, array(‘Accept-Charset: utf-8;q=0.7,*;q=0.7’));
    $contents = curl_exec ($curl);
    $content_type = curl_getinfo( $curl, CURLINFO_CONTENT_TYPE );
    curl_close ($curl);
    }
    else
    {
    $handle = @fopen ($page_url, ‘r’);
    if ($handle) {
    stream_set_blocking($handle, TRUE );
    stream_set_timeout($handle, 2);
    $info = socket_get_status($handle);
    while (!feof($handle) && !$info[‘timed_out’]) {
    $contents .= fread($handle, 8192);
    $info = socket_get_status($handle);
    }
    @fclose($handle);
    }
    }
    return $contents;
    }

    klandis79

    (@klandis79)

    @timwarner69 Thanks – that was a big help to include that. I also found I had a typo in the variable name in this function for the curl opt URL. I corrected that below and was able to confirm a test using my own application token that I get the ESV scripture back in the function.

    You should be able to use this code to replace you sb_download_page function, but remember to insert your own ESV V3 API application token in place of my “###VALUE-FROM-API.ESV.ORG-SETUP###” comment.

    //Downloads external webpage. Used to add Bible passages to sermon page.
    function sb_download_page ($page_url) {
    	if (function_exists('curl_init')) {
    		$curl = curl_init();
    		curl_setopt_array($curl, array(
    			CURLOPT_URL => $page_url,
    			CURLOPT_RETURNTRANSFER => true,
    			CURLOPT_ENCODING => "",
    			CURLOPT_MAXREDIRS => 10,
    			CURLOPT_TIMEOUT => 30,
    			CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    			CURLOPT_CUSTOMREQUEST => "GET",
    			CURLOPT_HTTPHEADER => array(
    		"authorization: Token ###VALUE-FROM-API.ESV.ORG-SETUP###",
    		"cache-control: no-cache"
    		),
    		));
    		
    		$contents = curl_exec ($curl);
    		$content_type = curl_getinfo( $curl, CURLINFO_CONTENT_TYPE );
    		
    		$response = curl_exec($curl);
    		$err = curl_error($curl);
    
    		curl_close($curl);
    
    		$json = json_decode($response, true);
    		$contents = $json["passages"][0];
    	}
    	else
    		{
    		$handle = @fopen ($page_url, 'r');
    		if ($handle) {
    			stream_set_blocking($handle, TRUE );
    			stream_set_timeout($handle, 2);
    			$info = socket_get_status($handle);
    			while (!feof($handle) && !$info['timed_out']) {
    				$contents .= fread($handle, 8192);
    				$info = socket_get_status($handle);
    			}
    		@fclose($handle);
    		}
    	}
    	return $contents;
    }
    timwarner69

    (@timwarner69)

    @klandis79 thank you so much for all your time and trouble… however that’s just killed the site it seems ?? I just get a blank screen now when I try to access the site at staging.thurnbychurch.com

    I took a backup of fronted.php before I added the edits & the site returns fine when I place the backup back in the folder, but the minute I add that second part of the code amend (sb_download_page) it just crashes out the site.

    Any ideas? I feel really bad to keep asking, but I just can’t work out what’s going wrong…

    klandis79

    (@klandis79)

    @timwarner69 did you check to make sure the insertion of the code was properly formed? I know I have seen sometimes the code apostrophe copy from the forums, so there is a chance that caused a problem or something else. However, it should not stop the site from responding since this is only called on the sermon detail page.

    If you want, shoot me an email [email protected] with your revised frontend.php and I’ll take a look. You can see here I installed sermon browser and tested the code change on my Church’s website on this test page to see if the reference was pulled in: https://www.cantonbiblechurch.org/a-test/?sermon_id=1 Elsewhere on the site, we use a different plugin, but it has the same concept.

    Also, are you running the latest WordPress version or are you backlevel? I would also assume your server can use CURL since it exists in the current frontend.php version.

    klandis79

    (@klandis79)

    I worked with @timwarner69 to get this resolved and have a copy of frontend.php if anyone needs to update their copy for ESV to resolve this issue.

    timwarner69

    (@timwarner69)

    Great work @klandis79 – thanks so much for all your help.

Viewing 15 replies - 16 through 30 (of 36 total)
  • The topic ‘Error loading bible verses’ is closed to new replies.