php - search query via http using JSON -
I am sending an API request and want to submit a search term within the URL:
$ Query = "My query"; $ Query_encode = urlencode ($ query); $ Url_json = "API_URL" $ Query_encode $ json = file_get_contents ($ url_json);
What I want to do is that there should be a more complex word in "My query" such as:
"word1 word2" (word3 or word4) And Word5
My problem is that I want to get results from the API (database) that matches "word1 word2", so send me quote marks through http in some way is required.
Does anyone have an idea that I need to set the contents of my query, which includes the necessary quotation marks, to send a question with the phrase, not just the word
$ query = "My query";
If you want to send a quote then include it in your query.
If you set a string value inside the quote in PHP, then whatever you have is not an extra quote, which you want to send along with on request, the quotes will be parsed and by PHP Will be removed.
You should do something like this:
$ query = '' My query '';
To get back to
"My Query" like this, it's something like
% 22My + query% 22
urldecode as string value.
Comments
Post a Comment