query-string

node.js http 'get' request with query string parameters

China☆狼群 提交于 2020-01-27 09:07:18
问题 I have a Node.js application that is an http client (at the moment). So I'm doing: var query = require('querystring').stringify(propertiesObject); http.get(url + query, function(res) { console.log("Got response: " + res.statusCode); }).on('error', function(e) { console.log("Got error: " + e.message); }); This seems like a good enough way to accomplish this. However I'm somewhat miffed that I had to do the url + query step. This should be encapsulated by a common library, but I don't see this

Prevent user from manipulating query string parameter

牧云@^-^@ 提交于 2020-01-25 04:26:08
问题 Situation: Unregistered user visits website and issues a request for an item. As per the current data flow, this request gets inserted in db first and the request id is carried over in the url of the subsequent pages henceforth( where user gets to add in further info). Problem: User can change the id. What i have done so far: As soon as i retrieve the id after request is inserted by using lastInsertId(), i store it inside a session variable and check in the subsequent pages against the id

Shortest possible query string for a numerically indexed array in PHP

微笑、不失礼 提交于 2020-01-25 03:26:44
问题 I’m looking for the most concise URL rather than the shortest PHP code. I don’t want my users to be scared by the hideous URLs that PHP creates when encoding arrays. PHP will do a lot of repetition in query string if you just stuff an array ( $fn ) through http_build_query: $fs = array(5, 12, 99); $url = "http://$_SERVER[HTTP_HOST]/?" . http_build_query(array('c' => 'asdf', 'fs' => $fs)); The resulting $url is http://example.com/?c=asdf&fs[0]=5&fs[1]=12&fs[3]=99 How do I get it down to a

How to pass query string parameters to the PHP binary?

不羁的心 提交于 2020-01-23 08:14:07
问题 I am developing a webserver that invokes the PHP binary (via CGI) to process a script. Here's the problem: The PHP script isn't picking up the command line parameters. For example, if the client requests path/to/file.php?test=value , the $_GET array is empty. I have tried passing the parameters in an environment variable ( QUERY_STRING ), but they still don't show up. How can I pass query string parameters to a PHP application? 回答1: There are various SAPIs for PHP. One of them is cli SAPI

How should I encode dictionaries into HTTP GET query strings?

折月煮酒 提交于 2020-01-23 06:14:12
问题 An HTTP GET query string is a ordered sequence of key/value pairs: ?spam=eggs&spam=ham&foo=bar Is, with certain semantics, equivalent to the following dictionary: {'spam': ['eggs', 'ham'], 'foo': bar} This happens to work well for boolean properties of that page being requested: ?expand=1&expand=2&highlight=7&highlight=9 {'expand': [1, 2], 'highlight': [7, 9]} If you want to stop expanding the element with id 2, just pop it out of the expand value and urlencode the query string again. However

How should I encode dictionaries into HTTP GET query strings?

丶灬走出姿态 提交于 2020-01-23 06:11:16
问题 An HTTP GET query string is a ordered sequence of key/value pairs: ?spam=eggs&spam=ham&foo=bar Is, with certain semantics, equivalent to the following dictionary: {'spam': ['eggs', 'ham'], 'foo': bar} This happens to work well for boolean properties of that page being requested: ?expand=1&expand=2&highlight=7&highlight=9 {'expand': [1, 2], 'highlight': [7, 9]} If you want to stop expanding the element with id 2, just pop it out of the expand value and urlencode the query string again. However

Laravel 5 - NGINX Server Config Issue with URL Query Strings

耗尽温柔 提交于 2020-01-22 10:33:07
问题 Laravel is not receiving any $_GET variables from the URL query string. The $_GET and Input::all() are empty. Example: example.app/ex/login.php?country=US The "country=US" never shows up in my $_GET variable After much research and trying many different NGINX configurations, I can now only produce results when this example is used. Example: example.app/index.php/ex/login.php?country=US The $_GET variable now shows the country name value pair. What is the proper configuration to allow query

How to access a query-string in a javascript file

走远了吗. 提交于 2020-01-22 02:20:15
问题 Possible Duplicate: How can I get query string values? Lets say, we have a <script> tag like this in the HTML markup <script src="/path/file.js?test=1&data=2"></script> ..is there any way to access the query-string within file.js ? window.location does not change of course, so you can't use that for that. If this is not possible, how can you pass data into a script file ? 回答1: Musa has the right approach here (from the comments). You can access the script tag like any other (you can use an ID

Persistent URL query string throughout the entire site?

自古美人都是妖i 提交于 2020-01-22 00:41:30
问题 This is one of those situations where I feel like there is a simple answer right in front of me...hopefully you guys/gals can show me the light. PROBLEM : I have a client that wants to maintain a query string across all pages on their site, only if they arrived at the site via a link that contains the query string. This query string would also need to be passed with any external link from the site. INFORMATION : An example of the query string : ?utm_medium=<ad_placement>&utm_source=<ad_source

Persistent URL query string throughout the entire site?

耗尽温柔 提交于 2020-01-22 00:41:04
问题 This is one of those situations where I feel like there is a simple answer right in front of me...hopefully you guys/gals can show me the light. PROBLEM : I have a client that wants to maintain a query string across all pages on their site, only if they arrived at the site via a link that contains the query string. This query string would also need to be passed with any external link from the site. INFORMATION : An example of the query string : ?utm_medium=<ad_placement>&utm_source=<ad_source