NotionCommotion
Members-
Posts
2,446 -
Joined
-
Last visited
-
Days Won
10
Everything posted by NotionCommotion
-
How to quickly find the matching curly brace?
NotionCommotion replied to tommytx's topic in PHP Coding Help
Yes, but how did you know? -
How to quickly find the matching curly brace?
NotionCommotion replied to tommytx's topic in PHP Coding Help
You want to press down the shift button and the control button at the same time, then click q three times really fast, then slowly b, z, 9, and finally F12 but be sure to also press down the escape button for the F12. At least, this works for the application I am using. What application are you using? -
Hi 1inaminion, First of all, good job putting your PHP logic one place (You put it at the top of the page which is fine, just don't mix it in your HTML) and your html template another. There are template systems such as smarty which take this a little bit further, but I recommend you keep doing what you are doing for a while, and then look into templates. You should be proud of yourself! Do you have a decent understanding of HTML/CSS? If so, PHP is not magic. It just spits out some HTML to the browser (and sometimes other things, but let's not worry about that for now). Just look at the HTML. Is it what you expected and wanted? If not, then your PHP script needs to be tweaked. Good luck and have fun!
-
I had skimmed it, but did not read it in detail. The reasons I did not read it in detail are: It appeared to deal with writing server logs (see below sections), and not meeting my objectives. Are they referring to "logs" different than https://dev.mysql.com/doc/refman/5.7/en/server-logs.html? I am concerned that MySQL-to-MySQL communication will not give adequate networking, operability, or authentication flexibility. But considering I didn't read it in detail, I do not know this for sure. --stop-never This option is used with --read-from-remote-server. It tells mysqlbinlog to remain connected to the server. Otherwise mysqlbinlog exits when the last log file has been transferred from the server. --stop-never implies --to-last-log, so only the first log file to transfer need be named on the command line. --read-from-remote-server, -R Read the binary log from a MySQL server rather than reading a local log file. Any connection parameter options are ignored unless this option is given as well. These options are --host, --password, --port, --protocol, --socket, and --user. This option requires that the remote server be running. It works only for binary log files on the remote server, not relay log files. This option is like --read-from-remote-master=BINLOG-DUMP-NON-GTIDS. --to-last-log, -t Do not stop at the end of the requested binary log from a MySQL server, but rather continue printing until the end of the last binary log. If you send the output to the same MySQL server, this may lead to an endless loop. This option requires --read-from-remote-server.
-
Thank you, Well, I did say I wanted data on regular intervals, but in retrospect, I feel that getting data when it has significantly changed is better. And gotcha about how websockets are for browsers and plain old sockets for for PHP, etc I am in complete agreement with you. Can you please elaborate on the criteria which would make one solution more suitable than another?
-
I have a LAMP server which will also act as a client (furthermore referred to as PHP client). The PHP client's purpose is to periodically make cURL requests to other servers and store the responses in the DB, and should do so indefinitely. The remote server IPs and poll rates are stored in the PHP client's DB. Some of the remote server are polled every 15 seconds, others are polled every 1 minute, others are polled every 5 minutes, and others are polled every 15 minutes, and a given remote server's poll rate will never change (at least not without some manual manipulation). New remote servers may be added in the future. While poll rates should on average be close to the designed poll rate, they do not need to be exact. All the remote servers do not need to be polled at the same time, and ideally will not be. Currently, I am polling all remote servers every 15 seconds. To implement it, I've created a daemon which performs an endless loop. Each loop, it executes a PHP script in the background, and then sleeps for 15 seconds. The PHP script retrieves all of the remote server's IP, makes cURL requests to the remote servers in order, and stores the data. I feel there are likely much better ways to do so. Any recommendations? Thank you
-
Should terminating semicolons always be used?
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
That was exactly what caused my problem. I had a file which worked perfectly, but then removed the trailing closing php tag, and thinking nothing could ever go wrong (yea, right), didn't test it, and discovered the error the hard way. -
Should terminating semicolons always be used?
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Okay, "maybe" they would be nice when using PHP as a template engine. I personally, however, would rather have PHP complain about it as a syntax error. Thanks -
I had the following script in a file. I then decided to updated all my files and remove the closing ?>. Later found I had an error. <?php // bla bla bla $site=new site(); $site->execute() ?> But why did it originally work? My lack of a closing semicolon was simple a oversight and not my intention. Then I read http://php.net/manual/en/language.basic-syntax.instruction-separation.php: Okay, now I know. But why does PHP have such a "feature" of not needing a semicolon at the end of a PHP block? Does it provide any value?
-
How to access a PHP variable in both CSS and HTML?
NotionCommotion replied to MythicalTomatoSoup's topic in PHP Coding Help
Hello Mythical, The part you need to understand is that PHP lives on the server, and HTML/CSS/JS lives on the client browser. The only way to can use them on both is if you send the variables from one to another. One option is for PHP to create a web page and for PHP to echo your random time both within your CSS and within a hidden input. By echoing it, you are writing it or sending it from the server to the client. Then when the user fills out the form, both the hidden input and the timeguess input are posted or sent to the server. Some recommend not using PHP to dynamically generate CSS (or JS for that mater), and another alternative would be to echo an attribute such as data-time in you HTML, and use JS of the color changing. Good luck! -
Checking if array exists in another array
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Thanks Kicken, Yes, I had first tried this as arrays, and saw that it also worked. What more surprised me was that ['a'=>1,'b'=>1,'c'=>2] and ['b'=>2,'a'=>2,'c'=>1] produced the same results. I guess I expected that PHP would interpret them as their string equivalent. -
I didn't expect the following to work, but then tried it and it does. Any gotchas I need to look out for? <?php $haystack=[ (object)['a'=>1,'b'=>1,'c'=>1], (object)['a'=>1,'b'=>2,'c'=>1], (object)['a'=>2,'b'=>1,'c'=>2], (object)['a'=>2,'b'=>2,'c'=>1], (object)['a'=>2,'b'=>2,'c'=>2], ]; var_dump(in_array((object)['a'=>2,'b'=>2,'c'=>1],$haystack)); //True var_dump(in_array((object)['a'=>1,'b'=>1,'c'=>2],$haystack)); //False var_dump(in_array((object)['b'=>2,'a'=>2,'c'=>1],$haystack)); //True
-
I was reviewing the following lines of code. <?php namespace Concrete\Block\Html; use Loader; use \Concrete\Core\Block\BlockController; class Controller extends BlockController { Turns out BlockController.php is located at /var/www/concrete5.7.5.9/concrete/src/Block/BlockController.php. Other than a brute search for "class BlockController", how should I find the file?
-
How to validate/test a REST API against a spec?
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
I haven't spent that much time so far, however, am sure I am not yet done. For instance, the testing application should test all permutations of data sent (i.e. make a parameter a string, an integer, zero, don't include it, etc) and check for errors. Likely, I will end up spending too much time. Do you recommend a framework or other particular tools? Thanks -
I recently created an OpenAPI https://openapis.org/ (aka Swagger) spec and then built an application to implement that spec. How can I test my application to ensure that it accurately implements the spec? Are there any tools to assist? I looked around and couldn't find anything I liked, and started building my own. To test, you specify an endpoint and any data to send as well as the expected HTTP status code to be returned, and the class confirms that all required inputs are provided, that no inputs not described by the spec are provided, that all required outputs are returned, and that no outputs not described by the spec are returned, and also that the returned status code was returned. I keep on thinking, however, that there has to be something good already built. Did I totally waste my time? <?php require('../classes/TestAPI.php'); $test=new TestAPI(file_get_contents ('/var/www/swagger/swagger-ui/dist/swagger.json')); $test->preloadHeaders(['X-GreenBean-Key'=>'main_key']); $rsp=$test->test('/charts/pie','post',[],json_decode('{"name": "My Chart","theme":"invalid"}',true),200); $rsp=$test->test('/charts/pie','post',[],json_decode('{"name": "My Chart","theme":"invalid"}',true),422); $rsp=$test->test('/charts/pie','post',[],json_decode('{"name": "My Chart","theme":"pie1"}',true),200); $id=$rsp->id; $rsp=$test->test('/charts/{id}','get',['id'=>$id],[],200); $rsp=$test->test('/charts/{id}','put',['id'=>$id],['name'=>'title','value'=>'My Title'],204); $rsp=$test->test('/charts/{id}','post',['id'=>$id],['points_id'=>98,'legend'=>'Legend for Speed'],204); $rsp=$test->test('/charts/{id}','post',['id'=>$id],['points_id'=>99,'legend'=>'Legend for Cost'],204); $rsp=$test->test('/charts/{id}','get',['id'=>$id],[],200); $rsp=$test->test('/charts/{id}/{legend}','delete',['id'=>$id,'legend'=>'Legend for Speed'],[],204); $rsp=$test->test('/charts/{id}','get',['id'=>$id],[],200); $rsp=$test->test('/charts/{id}','delete',['id'=>$id],[],204); $rsp=$test->test('/charts/{id}','get',['id'=>$id],[],404); <?php class TestAPI { private $obj, $repeat, $data=[], $headers=[], $source=[]; public function __construct($json) { $this->obj = json_decode($json,true); if(json_last_error() !== JSON_ERROR_NONE) { throw new Exception('Invalid JSON'); } $this->repeat=true; while($this->repeat) { $this->repeat=false; $this->obj=$this->substituteReferences($this->obj); } unset($this->obj['definitions']); unset($this->obj['parameters']); unset($this->obj['responses']); $this->obj=$this->substituteAllOf($this->obj); } public function preloadData(array $arr) { // Preload data which will be sent with every request foreach($arr as $key=>$value) { $this->data[$key]=$value; } } public function preloadHeaders(array $arr) { // Preload headers which will be sent with every request foreach($arr as $key=>$value) { $this->headers[]=strtolower(str_replace("_","-",$key)).': '.$value; } } public function get() { return $this->obj; } private function getValue($name) { return isset($this->data[$name])?$this->data[$name]:false; } private function validateResponse($rsp,$config) { $errors=[]; if(!$rsp || !is_array($rsp) || count($rsp)!==2 || !isset($rsp['code']) || !isset($rsp['data'])) { $errors[]='Invalid response from server.'; } elseif(!isset($config['responses'][$rsp['code']])) { $errors[]="HTTP code $rsp[code] is not supported."; } else { $data=json_decode($rsp['data']); $type=isset($config['responses'][$rsp['code']]['schema']) ?isset($config['responses'][$rsp['code']]['schema']['type'])?$config['responses'][$rsp['code']]['schema']['type']:'object' :'NULL'; if(json_last_error() !== JSON_ERROR_NONE) { $errors[]="Server response is not JSON."; } elseif(gettype($data)!=$type) { $errors[]="Response type expected was $type, however, ".gettype($data)." was received"; } else { switch($type) { case 'array': /* foreach($x as $s) { } */ $status='OKAY'; break; case 'object': $data=(array)$data; $required=isset($config['responses'][$rsp['code']]['schema']['required'])?$config['responses'][$rsp['code']]['schema']['required']:[]; $properties=isset($config['responses'][$rsp['code']]['schema']['properties'])?$config['responses'][$rsp['code']]['schema']['properties']:[]; $propertyNames=array_keys($data); if($missing=array_diff($required,$propertyNames)) { $errors[]='Missing required response properties '.implode(', ',$missing); } if($toMany=array_diff($propertyNames,array_keys($properties))) { $errors[]='Unexpected response properties '.implode(', ',$toMany); } else { //Don't validate response types if too many were given foreach($data as $property=>$value) { $type=gettype($value); if($type!=$properties[$property]['type']) { $errors[]="Respond property $property is type $type but should have been type $properties[$property][type]."; } } } break; case 'string': break; case NULL: break; // Test for null? default: $status="Non-supported response type $type. This should never happen!"; } } } return $errors; } private function substitute($path, $parameters) { foreach ($parameters as $key => $value) { $path = str_replace('{'.$key.'}', urlencode($value), $path); } return $path; } public function testAll() { foreach($this->obj['paths'] as $path=>$methods) { foreach ($methods as $method=>$config) { $url=$this->obj['host'].$this->obj['basePath'].$path; $rsp=$this->CallAPI($method, $url, $this->data, $this->headers); $errors=$this->validateResponse($rsp,$config); echo("<p>URL: $url Method: $method Status: ".(empty($errors)?'OKAY':'ERROR')."</p>"); if($errors) {echo('<pre>'.print_r($errors,1).'</pre>');} //echo('<pre>'.print_r($rsp,1).'</pre>'); } //echo('<pre>'.print_r($path,1).'</pre>'); } } public function test($path,$method,array $params, array $data, $expected=null) { $url=$this->obj['host'].$this->obj['basePath'].($params?$this->substitute($path,$params):$path); $rsp=$this->CallAPI($method, $url, array_merge($data,$this->data), $this->headers); echo("<h3><u>REQUEST</u></h3><p>Path: $path</p><p>Method: $method</p><p>Parameters: ".json_encode($params)."</p><p>Data: ".json_encode($data)); echo("<h3><u>RESPONSE</u></h3><p>Code: $rsp[code]</p><p>Data: $rsp[data]"); echo("<h3><u>VALIDATION</u></h3>"); if(isset($this->obj['paths'][$path][$method])) { $errors=$this->validateResponse($rsp,$this->obj['paths'][$path][$method]); if($expected && $expected!=$rsp['code']) { $errors[]='HTTP Code does not match expected code "'.$expected.'".'; } if($errors) { echo('<p>ERROR</p><pre>'.print_r($errors,1).'</pre>'); } else{ echo('<p>Valid</p>'); } } else { echo("INABILITY TO VALIDATE: INVALID PATH ($path) OR METHOD ($method)"); } echo('<hr>'); return json_decode($rsp['data']); } private function substituteReferences($o) { foreach($o as $k=>$v) { if(is_array($v)){ $o[$k]=$this->substituteReferences($v); } elseif($k==='$ref') { if(substr($v,0,2)!='#/') throw new Exception('Invalid reference: Bad prefix.'); $p=explode('/',substr($v,2)); if(count($p)!=2) throw new Exception('Invalid reference: Incorrect count.'); if(empty($this->obj[$p[0]])) throw new Exception('Invalid reference: Property type doesn\'t exist.'); if(empty($this->obj[$p[0]][$p[1]])) throw new Exception('Invalid reference: Property doesn\'t exist.'); $o=$this->obj[$p[0]][$p[1]]; $this->repeat=true; } elseif($k==='in' && $v==='header' && isset($o['name'])) { //Make compatible $o['name']=strtolower(str_replace("_","-",$o['name'])); } } return $o; } private function substituteAllOf($o) { foreach($o as $k=>$v) { if($k==='allOf') { $properties=[]; $required=[]; foreach ($o['allOf'] as $key=>$item) { $properties=array_merge($properties, $item['properties']); if(isset($item['required'])) { $required=array_merge($required, $item['required']); } } unset($o['allOf']); $o['properties']=$properties; $o['required']=$required; } elseif(is_array($v)){ $o[$k]=$this->substituteAllOf($v); } } return $o; } private function CallAPI($method, $url, $data, array $headers=[], $options=[], $debug=false) { $options=$options+[ //Don't use array_merge since it reorders! CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "unknown",// who am i CURLOPT_AUTOREFERER => true, // set referrer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_SSL_VERIFYPEER => false // Disabled SSL Cert checks. FIX!!!!!!!!! ]; //Optional authentication if (isset($options[CURLOPT_USERPWD])) {$options[CURLOPT_HTTPAUTH]=CURLAUTH_BASIC;} switch (strtolower($method)) { case "get": if ($data) {$url = sprintf("%s?%s", $url, http_build_query($data));} break; case "post": $options[CURLOPT_POST]=1; if ($data) {$options[CURLOPT_POSTFIELDS]=$data;} break; case "put": //$options[CURLOPT_PUT]=1; $options[CURLOPT_CUSTOMREQUEST]="PUT"; if ($data) {$options[CURLOPT_POSTFIELDS]=http_build_query($data);} break; case "delete": //$options[CURLOPT_DELETE]=1; $options[CURLOPT_CUSTOMREQUEST]="DELETE"; if ($data) {$options[CURLOPT_POSTFIELDS]=http_build_query($data);} break; default:trigger_error("Invalid HTTP method.", E_USER_ERROR); } //$this->logger->addInfo("$method $url ".json_encode($data)); $options[CURLOPT_URL]=$url; $ch = curl_init(); curl_setopt_array( $ch, $options ); if($headers) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } $rsp = curl_exec( $ch ); if($debug) { $results = array_merge(curl_getinfo( $ch ),['errno'=>curl_errno($ch), 'errmsg'=>curl_error($ch),'data'=>$rsp,'code'=>curl_errno($ch)?null:curl_getinfo($ch, CURLINFO_HTTP_CODE)]); } else { $results=curl_errno($ch)==6 ?['data'=>json_encode(['message'=>'Invalid Datalogger IP','code'=>1]),'code'=>400] :['data'=>$rsp,'code'=>curl_getinfo($ch, CURLINFO_HTTP_CODE)]; } curl_close( $ch ); return $results; } }
-
Thank you! Should an OPTIONS request always positively? For instance, should every PHP script which responds to HTTP requests have the following few lines? <?php if ($_SERVER['REQUEST_METHOD']==='OPTIONS') { http_response_code(200); exit; } // remaining code goes here.... EDIT. Or should apache/etc or php.ini be set up so it never gets to PHP?
-
I am using a header for authentication of an api. If the header is not included, I send back a 401 code. $key = $request->getHeaderLine('X-GreenBean-Key'); if (empty($key)) { $error=\MyApp\ErrorResponse::missingKey(); return $response->withJson($error[0], $error[1]); } Problem is my server is being hit twice, the first time without the header, and thus the client never attempts the second request. The request is cross-domain, and thus I added the header name to Access-Control-Allow-Headers. Below is my test scripts documenting what appears to be happening. What am I doing wrong??? ajax.html <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Testing</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $.ajax({ type:'GET', url:'http://example.com/ajax', headers: {"X-Greenbean-Key": "main_key"} }) }); </script> </head> <body></body> </html> ajax.php <?php require __DIR__.'/../vendor/autoload.php'; $logger = new \Monolog\Logger('my_logger'); $file_handler = new \Monolog\Handler\StreamHandler("../logs/testing.log"); $logger->pushHandler($file_handler); $logger->addInfo('Server Hit. Header: '.$_SERVER['HTTP_X_GREENBEAN_KEY']); testing.log (for Monolog) [2016-10-03 05:25:14] my_logger.INFO: Server Hit. Header: [] [] [2016-10-03 05:25:14] my_logger.INFO: Server Hit. Header: main_key [] [] log (apache) 192.168.1.1 - - [03/Oct/2016:05:25:14 -0700] "OPTIONS /ajax.php HTTP/1.1" 200 134 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0 FirePHP/0.7.4" 192.168.1.1 - - [03/Oct/2016:05:25:14 -0700] "GET /ajax.php HTTP/1.1" 200 - "http://dd.badobe.com/ajax.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0 FirePHP/0.7.4" httpd.conf <VirtualHost *:80> ServerName example.com DocumentRoot /var/www/src/public <Directory "/var/www/src/public"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all RewriteEngine On Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" Header set Access-Control-Allow-Headers "X-Greenbean-Key, Origin, X-Requested-With, Content-Type, Accept" </Directory> </VirtualHost>
-
$response->withJson() accepts an array which will be transformed to JSON as well as an optional integer which specifies the HTTP status code (if not given, uses 200). Alternatively, I can use $response->withStatus($desiredCode); to set the HTTP status code. Is there a more concise way to perform the following? $rs=myFunction(); return $response->withJson($rs['array'],$rs['code']); // or return $response->withJson($rs['array'])->withStatus($rs['code']); PS. This relates to the Slim framework, and I don't wish to modify the script related to $response. Edit. Other than use using something like $rs[0] and $rs[1].
-
automatically populating $HTTP_RAW_POST_DATA
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Thanks Requinix, By the way, I am using PHP 5.6.25. This is about as minimal as I can get. The headers might not have anything to do with it. Maybe I am not passing JSON, but passing a form with what I thought was JSON in it? Still have a hard time grasping what is happening, and would appreciate any insight. My purpose is to allow cross domain posts, and the headers came from swagger's documentation. I am thinking of getting rid of them, and just adding Header set Access-Control-Allow-Origin "*" to httpd.conf. always_populate_raw_post_data set to default (0?) -sh-4.1$ curl -X POST --header 'Accept: application/json' --header 'api_key: main_key' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_no_set_headers.php' array(1) { ["{_"property_one":_"string",_"property_two":_"string"_}"]=> string(0) "" } -sh-4.1$ curl -X POST --header 'Content-Type: application/json' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_no_set_headers.php' <br /> <b>Deprecated</b>: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br /> array(0) { } -sh-4.1$ curl -X POST --header 'Accept: application/json' --header 'api_key: main_key' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_set_headers.php' array(1) { ["{_"property_one":_"string",_"property_two":_"string"_}"]=> string(0) "" } -sh-4.1$ curl -X POST --header 'Content-Type: application/json' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_set_headers.php' <br /> <b>Deprecated</b>: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent in <b>/var/www/test/src/public/headertest_set_headers.php</b> on line <b>3</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent in <b>/var/www/test/src/public/headertest_set_headers.php</b> on line <b>4</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent in <b>/var/www/test/src/public/headertest_set_headers.php</b> on line <b>5</b><br /> array(0) { } always_populate_raw_post_data set to -1 -sh-4.1$ curl -X POST --header 'Accept: application/json' --header 'api_key: main_key' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_no_set_headers.php' array(1) { ["{_"property_one":_"string",_"property_two":_"string"_}"]=> string(0) "" } -sh-4.1$ curl -X POST --header 'Content-Type: application/json' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_no_set_headers.php' array(0) { } -sh-4.1$ curl -X POST --header 'Accept: application/json' --header 'api_key: main_key' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_set_headers.php' array(1) { ["{_"property_one":_"string",_"property_two":_"string"_}"]=> string(0) "" } -sh-4.1$ curl -X POST --header 'Content-Type: application/json' -d '{ "property_one": "string", "property_two": "string" }' 'http://test.example.com/headertest_set_headers.php' array(0) { } -sh-4.1$ <?php //headertest_set_headers.php header('Access-Control-Allow-Origin: http://swagger-ui.badobe.com'); header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept, Origin, Authorization'); header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); var_dump($_REQUEST); exit; <?php //headertest_no_set_headers.php var_dump($_REQUEST); exit; -
automatically populating $HTTP_RAW_POST_DATA
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
grep -rnw . -e "HTTP_RAW_POST_DATA" doesn't show anything. You feel confident that I must be somehow using it, and should look deeper? Recommendations where to look? Thanks -
automatically populating $HTTP_RAW_POST_DATA
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
I searched for the term HTTP_RAW_POST_DATA in all my script, and it doesn't exist.