Square-Connect Webhook PHP post no data -


i have square-connect webhooks endabled. receiving post's server script. yet $_post array seems empty.

here code:

<?php    $srm = $_server['request_method'] ;    $sh = null ;        if ( 'put' == $srm )    {      $sh = file_get_contents( 'php://input' ) ;    }    else if ( 'post' == $srm )    {      $ss = '' ;            foreach( $_post $sk => $sv )      {        $sh .= $sk.'=>'.$sv ;        $ss = ', ' ;      }    }        if ( connectdb() )    {      $_session[ 'db' ]->real_escape_string( trim( $sh ) ) ;  //  prevent sql injection      $rr = $_session[ 'db' ]->query( 'insert `hooks` ( `method`,`message` ) values ( "'.$srm.'", "'.$sh.'" ) ;' ) ;    }  ?>

thanks, rob

the square docs state post body in json format, php not parse form , populate $_post array. need this:

$json = file_get_contents('php://input'); $obj = json_decode($json); 

as described in answers reading json post using php.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -