Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix unable to get url parameters

Discussion in 'Misc WordPress Requests' started by miladaslani, Nov 8, 2017.

  1. miladaslani

    Guest

    unable to get url parameters, by miladaslani

    hi,
    i had this code

    function testFunction($data) {
    $data["params"] = str_replace("\\", "", $data["params"]);
    $q = json_decode($data["params"], TRUE);

    return $q;
    }

    add_action('rest_api_init', function () {
    register_rest_route('v3', '/page/test', array('methods' => 'GET', 'callback' => 'testFunction'));

    });

    and when i request to
    http://example.com/wp-json/v3/page/home?params={"year":"1396","month":"8","day":"17","page":"4"}
    I get this answer

    {
    "year": "1396",
    "month": "8",
    "day": "17",
    "page": "4"
    }

    but after I change my site protocol to ssl, I get null for url parameters
    my request url is :
    https://example.com/wp-json/v3/page/home?params={"year":"1396","month":"8","day":"17","page":"4"}

    unable to get url parameters
     
    #1

Share This Page

Web Hosting