Each YouTube video has four generated images. They are predictably formatted as follows:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (i.e., one of 1.jpg
, 2.jpg
, 3.jpg
) is:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a URL similar to this:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
There is also a medium quality version of the thumbnail, using a URL similar to the HQ:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
For the standard definition version of the thumbnail, use a URL similar to this:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
For the maximum resolution version of the thumbnail use a URL similar to this:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
All of the above URLs are available over HTTP too. Additionally, the slightly shorter hostname i3.ytimg.com
works in place of img.youtube.com
in the example URLs above.
Alternatively, you can use the YouTube Data API (v3) to get thumbnail images.
As allways, the best way to protect a key is not to transmit it.
That said, we typically use a scheme, where every "API key" has two parts: A non-secret ID (e.g. 1234) and a secret key (e.g. byte[64]).
- If you give out an API key, store it (salted and hashed) in you
service's database.
- If you give out user accounts (protected by password), store the
passwords (salted and hashed) in your service's database
Now when a consumer first accesses your API, to connect, have him
- Send a "username" parameter ("john.doe" not secret)
- Send a "APIkeyID" parameter ("1234", not secret)
and give him back
- the salts from your database (In case one of the parameters is wrong,
just give back some repeatable salt - eg.
sha1(username+"notverysecret").
- The timestamp of the server
The consumer should store the salt for session duration to keep things fast and smooth, and he should calculate and keep the time offset between client and server.
The consumer should now calculate the salted hashes of API key and password. This way the consumer has the exact same hashes for password and API key, as what is stored in your database, but without anything seceret ever going over the wire.
Now when a consumer subseqently accesses your API, to do real work, have him
- Send a "username" parameter ("john.doe" not secret)
- Send a "APIkeyID" parameter ("1234", not secret)
- Send a "RequestSalt" parameter (byte[64], random, not secret)
- Send a "RequestTimestamp" parameter (calculated from client time and known offset)
- Send a "RequestToken" parameter (hash(passwordhash+request_salt+request_timestamp+apikeyhash))
The server should not accept timestamps more than say 2 seconds in the past, to make this safe against a replay attack.
The server can now calculate the same hash(passwordhash+request_salt+request_timestamp+apikeyhash) as the client, and be sure, that
- the client knows the API key,
- the client knows the correct password
Best Solution
If someone is looking for OpenCart 3 then this may help:
How to pull products json through API in Opencart?
View this youtube video , it describes how to make custom OpenCart API and give details how to use it.
In Responding server, go to catalog/controller/api/ and create product.php and paste following lines of code:
In your requesting server, create a file lets say apiproducts.php, and paste the following code and run it:
You will get the response like below:
You can check following Opencart API related posts:
https://webocreation.com/blog/pull-products-json-through-ap-opencart https://webocreation.com/blog/opencart-api-documentation-to-create-read-query-update-and-upsert https://webocreation.com/blog/opencart-api-documentation-developer