How do I serialize an object into query-string format?

I’m 99% sure there’s no built-in utility method for this. It’s not a very common task, since a web server doesn’t typically respond with a URLEncoded key/value string. How do you feel about mixing reflection and LINQ? This works: var foo = new EditListItemActionModel() { Id = 1, State = 26, Prefix = “f”, Index … Read more

OK to skip slash before query string?

As a matter of modern spec, yes, it is permissible to skip the slash, contrary to what the accepted answer here claims. Although the accepted answer correctly quotes RFC 1738 (released over 20 years ago!), it wrongly claims that RFC 2396 (released in 1998) requires the slash, and neglects that both of those specs have … Read more

How do I parse a URL query parameters, in Javascript? [duplicate]

Today (2.5 years after this answer) you can safely use Array.forEach. As @ricosrealm suggests, decodeURIComponent was used in this function. function getJsonFromUrl(url) { if(!url) url = location.search; var query = url.substr(1); var result = {}; query.split(“&”).forEach(function(part) { var item = part.split(“=”); result[item[0]] = decodeURIComponent(item[1]); }); return result; } actually it’s not that simple, see the … Read more

JavaScript query string [closed]

You can extract the key/value pairs from the location.search property, this property has the part of the URL that follows the ? symbol, including the ? symbol. function getQueryString() { var result = {}, queryString = location.search.slice(1), re = /([^&=]+)=([^&]*)/g, m; while (m = re.exec(queryString)) { result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); } return result; } // … … Read more

PHP file_get_contents() returns “failed to open stream: HTTP request failed!”

Try using cURL. <?php $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_URL,’http://###.##.##.##/mp/get?mpsrc=http://mybucket.s3.amazonaws.com/11111.mpg&mpaction=convert format=flv’); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_USERAGENT, ‘Your application name’); $query = curl_exec($curl_handle); curl_close($curl_handle); ?>

How to pass multiple parameters in a querystring

Query_string (Following is the text of the linked section of the Wikipedia entry.) Structure A typical URL containing a query string is as follows: http://server/path/program?query_string When a server receives a request for such a page, it runs a program (if configured to do so), passing the query_string unchanged to the program. The question mark is … Read more

How do I use regex in a SQLite query?

As others pointed out already, REGEXP calls a user defined function which must first be defined and loaded into the the database. Maybe some sqlite distributions or GUI tools include it by default, but my Ubuntu install did not. The solution was sudo apt-get install sqlite3-pcre which implements Perl regular expressions in a loadable module … Read more