Viewing 2 replies - 1 through 2 (of 2 total)
  • We have the same question for our website karate stream

    We would need to export articles as JSON with protected password.

    Hi!

    This Code For YOU . i love Json Api

    Please Insert This Code To Your Theme Function.php
    ////////////////////////////////////////////////////////

    <?php
    
    /* place in theme's functions.php file */
    /* disable json api if api key not correct */
    
    add_action('init','json_api_apikey_check' , 1 );
    function json_api_apikey_check()
    {
    $api_key = 'yoursecterkey';
    $base = get_option('json_api_base', 'api');
    $this_url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    
    if ( ( isset($_REQUEST['json'] ) || strstr($this_url , $base.'/') ) && ( !isset($_REQUEST['apikey']) || $_REQUEST['apikey'] != 'yoursecterkey' ) )
    {
    
    header("Location: https://www.yourdomain.com/");
    exit;
    }
    }
    ?>
    //////////////////////////////////////////////////
    dont forget to change 'yoursecterkey'
    dont forget to change 'https://www.yourdomain.com'
    
    https://domain.com/?json=1  --- not work and redirect to your domain home
    
    https://domain.com/?json=1&apikey=yoursecterkey ----- its work
    
     <!-- :D - JSON API IS BEST  ->

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code has now been damaged by the forum’s parser.]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Password protecting the JSON file?’ is closed to new replies.