Support » Plugin: Ultimate Endpoints With Rest Api » Post not working

  • Resolved rambo3000

    (@rambo3000)


    Hi Dipankar,

    Thanks for the great plugin.

    When I try to do post (instead of get), the response body contains only the parameters that I’ve sent, instead of actual response.

    e.g. if post body is: secret_key=123&param1=456
    the response looks like:
    {
    “status”: “OK”,
    “response”: “Connection OK”,
    “code”: 200,
    “data”: {
    “secret_key”: “123”,
    “param1”: “456”
    }
    }

    How can I fix this? I need post to transfer data safely.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author dipankarpal

    (@dipankarpal212)

    Hey @rambo3000 ,

    To get actual response you need to define the FILTER HOOK of that particular endpoint in your any functions.php file.

    By default this plugin return the REQUESTED PARAMS (as your code snippet says ) , if hook is not defined.

    For more info please go through our Tutorial Video , you can find it in the plugin admin page (Walk Through TAB).

    If you need further assistance , please let us know!

    Thanks,

    Thread Starter rambo3000

    (@rambo3000)

    Hi,

    Thank you for the response.

    I got it working: I’ve tried passing secret_key param in the post content as well, but it needs to be in URL.

    So if secret_key is in URL, other params can be in post content and are recognized.

    Thread Starter rambo3000

    (@rambo3000)

    Note, that when secret_key is forced into URL, this is a slight security hole – as URL requests are visible in web server logs and such.

    https://security.stackexchange.com/questions/12531/ssl-with-get-and-post

    you generally should not put secret information (passwords) in GET requests even with SSL, but use POST instead. Why? The URL with the sensitive information will generally be logged at both ends; e.g., in your browsers history list (https://www.example.com?user=me&password=MyPassword) as well as the logs on the server. POST information (especially with passwords) is generally not written to webserver logs, though obviously can be configured to be logged–so its best not to reuse (or use similar) passwords at different sites.

    So it would be very useful if your plugin would accept secret_key in post content.

    I am new to wordpress and I am trying to use your plugin.

    I viewed your video on youtube: https://www.youtube.com/watch?time_continue=29&v=yBMjCD2Km2Q&feature=emb_logo

    The endpoint works fine when the code snippet is not in my functions.php file. I get the following output:
    {“status”:”OK”,”response”:”Connection OK”,”code”:200,”data”:{“secret_key”:”UbSbECnz4EBRR7smOstFVSz0dUbpRK8F”,”param1″:”1″}}

    However, when I put the code snippet in my functions.php file, I am getting strange error message:
    “The site is experiencing technical difficulties.”

    Why is this happening?

    • This reply was modified 2 years, 6 months ago by vraiwp.

    This is my endpoint
    ———————-

    add_filter(“wcra_post_donate_callback” , “wcra_post_donate_callback_handler”);
    function wcra_post_donate_callback_handler($param){
    //$param = All GET/POST values will be received from endpoint
    //do your stuff here
    $user_id = $param[‘param1′];
    $data = get_user_by(‘id’, $user_id);

    return $data;
    }

    • This reply was modified 2 years, 6 months ago by vraiwp.
    • This reply was modified 2 years, 6 months ago by vraiwp.
    add_filter("wcra_post_donate_callback" , "wcra_post_donate_callback_handler");
    function wcra_post_donate_callback_handler($param){
    $user_id = $param['param1'];
    $data = get_user_by('id', $user_id);
    return $data;
    }

    Please try this code.

    Thanks @qaisbsharat !

    It worked, it was an error with the apostrophe character not being used. I don’t know how my keyboard typed a different character than the apostrophe, but it did.

    Thanks again. I would have never figured that out!

    Most welcome @vraiwp !
    Have a nice day.

    Plugin Author dipankarpal

    (@dipankarpal212)

    Please give us a rating and reviews, it will help us to improve things in future.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Post not working’ is closed to new replies.