Pregunta

This one may actually be 2 questions in one.

Studying some APIs I came across an api suggesting to have operand different from equal (=) inside the query string (http://www.salesboard.com/api/):

mycompany.salesboard.com/api/contacts?CompanyId!=5
or
mycompany.salesboard.com/api/contacts?Id<=5

Is that possible?? and by "possible" I mean: is that legal according to the standards? And if yes what are the possible problems to use such a url (compatibility, browser support, etc).

Now the second part of the question is: What is the best way to parse a URL such as this in PHP, has anyone ever used it?

PS: My question is not really problem but I thought it would be nice also for others to know.

¿Fue útil?

Solución

The standard for URIs is STD 66, which currently maps to RFC 3986.

In section 3.4, it is defined what the query component may contain. (Note that it can’t contain an unencoded <).

However, it does not define any meanings for characters (like =) that can appear in the query component. Using a format like key=value is just a convention as far as the general URI standard is concernced.

Specific URI schemes might define such meanings, but the http URI scheme doesn’t seem to.

So semantically, there is no difference between using foo/bar, CompanyId!=5, or CompanyId-is-not-equal-to-5. They are just characters and it’s up to the consumers to interpret them.

Licenciado bajo: CC-BY-SA con atribución
scroll top