Question

qIn rest API this short of URL appears:

http://api.example.com/v1/curated-content?location=india&contenttype=image&category=celeb&orderby=popularity&apikey=15svzH8qSy5yQuF52b068a40a69e

in my database I have content like location, category, apikey,contenttype etc.

How can I fetch these data when user makes request like in aboce URL?

Was it helpful?

Solution

You're basically asking how to access Parameters that were sent via GET-Method. All these Parameters can be accessed via the associative $_GET-Array in PHP.

So if location=india and you do

echo $_GET['location'];

that would output

india

When creating SQL-Queries from these variables keep in mind that the user could manipulate the URL and insert harmful values in your code (so called SQL-Injection). Always mask such data with the mysql_real_escape_string function in PHP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top