• Resolved VWebTech

    (@vfxlab)


    Hi
    The Plugin is working great , Thanks to the developers.

    I build website of Quotes , And An Android App Through Json – api plugin.
    Its like all can get my all quotes easily from ?json= command from web browser . Is there any way to turn it off ? way to turn off calls
    or secure it with some password ?

    Hope you pro guys have answer of it.
    And this will be Useful to all the json – api users too.

    https://wordpress.org/plugins/json-api/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi!

    This Code For YOU . i love Json Api

    Please Insert This Code To Your Theme Function.php

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    ////////////////////////////////////////////////////////
    
    <?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 = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    
    if ( ( isset($_REQUEST['json'] ) || strstr($this_url , $base.'/') ) && ( !isset($_REQUEST['apikey']) || $_REQUEST['apikey'] != 'yoursecterkey' ) )
    {
    
    header("Location: http://www.yourdomain.com/");
    exit;
    }
    }
    ?>
    //////////////////////////////////////////////////
    
    dont forget to change 'yoursecterkey'
    dont forget to change 'http://www.yourdomain.com'
    
    http://domain.com/?json=1  --- not work and redirect to your domain home
    
    http://domain.com/?json=1&apikey=yoursecterkey ----- its work
    
     <!-- :D - JSON API IS BEST  ->
    Thread Starter VWebTech

    (@vfxlab)

    Thank You Very Mush .
    This Little Trick Can Save My Text.

    thank you very much Goldenapps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How To Secure The json-api?’ is closed to new replies.