Announcement

Collapse
No announcement yet.

Routes Post ParseBody

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Routes Post ParseBody

    Hello,

    How i can have value of Post in routes ?

    PHP Code:

    public function postActionSmsTest(Request $requestResponse $response)
    {
      
    $GLOBALS['log']->warningjson_encode$_POST ) ); // this give below
    {"action":"outgoing","version":"30","phone_number" :"32470XXX","phone_id":"","phone_token":"","sen d_limit":"100","now":"1623005379580","settings_ver sion":"0","battery":"100","power":"2","network":"W IFI","log":"Checking for messages\n"}


    $data $request->getBodyContents(); // this give below

     
    "action=outgoing&version=30&phone_number=32470XXX&phone_id=&phone_token=&send_limit=100&now=16230 06219586&settings_version=0&battery=100&power=2&network=WIFI&log=%5B9%3A03%3A39+pm%5D%0AChecking+for +messages%0A"


    $data $request->getBodyContents();  // No Result

    $data $request->getParsedBody(); // No result

    $data json_decode(json_encode($_POST));  // $data->action : this is OK 

    Any this for have value ?
    And where i can $respond as Header Content Application/json ?

    if some one have a sample .. Thanks


  • #2
    item
    This code you have to add to the Controller. Of course you have to map this controller in routes.json file.

    After someone call url, your method should work with three variables:$params, $data, $request
    $params = parameters in URL ($_GET)
    $data = parameters in POST
    $request = headers

    Here you have example of my method:

    https://dubas.pro/c/?f32b9a0c6252b1b...Th8gdH9KHuJuBw

    Comment

    Working...
    X