- Tested with Java 8 and gradle
In terminal, inside projects folder "moviebookapp" run:
gradlew bootRun
to start the Spring REST API.
Once Spring is running (leave it running for PHP client or curl to work)
you can access the API with PHP client or using cUrl.
Both ways have a minimalistic guide below.
- Tested with PHP 7.4.11
In a new terminal, inside projects folder "php_client" run:
php -S localhost:8080 index.php
to start the php server with index.php template.
Next go to your browser and type address localhost:8080
The small and uncolorful page should be now in front of you.
Before fetching movies or books you must fetch the Json Web Token.
This is done by writing on the Username field "test" and on the Password field
the most secure password I did come up with, it is: "test".
Now you can enrich your life by fetching book information if you know the ISBN code.
ISBN code is 10 digits and here are some examples you can try it out with:
0375751548
221285045X
1425034489
If books are not your thing but you are in dire need for some movie information, well look no
further... this amazing service can provide it for you too!
You need to pass in title of a movie to search for but you can also provide year.
If you thought that those were your only options to work with, think again.
You can also change the value of plot information from Short to Full.
If you for some reason are sceptic about using PHP for this and you enjoy reading your
book and movie information from the commandline, well there is no better cure for it than trying out
the application with cUrl.
Because this is the more wilder approach you can open your commandline from anywhere, yes
tou do not need to be inside the project folders to make these command.
Just check if your system has curl by typing curl --version
If the terminal gave you good new, firstly fetch the Json Web Token by calling in Windows systems:
curl -X POST -v -H "Content-Type: application/json" -d "{"""username""":"""test""", """password""":"""test"""}" http://localhost:8081/authenticate
, but in other systems you don't have to get so weird with the "" just type:
curl -X POST -v -H "Content-Type: application/json" -d "{'username':'test', 'password':'test'}" http://localhost:8081/authenticate
The command should return this kind of provoking string, like:
{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0IiwiZXhwIjoxNjA1NTI5NDU2LCJpYXQiOjE2MDU0OTM0NTZ9.JfjLLJVUh1SYGzZfbUYisKEbKYsAYPuVa8gpoBa392s"}
Next copy only the character snake and paste it to your GET command, like this:
curl -X GET -v -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0IiwiZXhwIjoxNjA1NTI5NDU2LCJpYXQiOjE2MDU0OTM0NTZ9.JfjLLJVUh1SYGzZfbUYisKEbKYsAYPuVa8gpoBa392s" localhost:8081/getMovie/batman
By changing the ending of the url you can search different things.
For movies use localhost:8081/getMovie/<title>//
<title> is a must and for only "short" or "full" are allowed
For Books use localhost:8081/getBook/ISBN/
must be a 10 digit number.
Thanks!