Skip to content

A minimal working example of creating and authenticating a php GET request to an API, and converting the JSON response to a php object.

License

Notifications You must be signed in to change notification settings

pedramardakani/API_PHP_Fetch_Trailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

  1. Minimal PHP code to retrieve movie trailer links from TMDb API

Minimal PHP code to retrieve movie trailer links from TMDb API

This example code uses the TMDb API but is not endorsed or certified by TMDb.

  1. Subscribe to TMDb with a valid email address

  2. Get the API validation key

  3. Read terms-of-use

  4. Authenticate the api

  5. Use the manual

  6. Add the video ID like this:

    https://www.youtube.com/watch?v={{video_id}}

  7. Check if PHP cURL is available already curl --version if not, just Configure curl on machine

  8. Use the cURL documentation to write a simple script

  9. Get the trailer link via TMDb API

  10. Embed youtube trailer of the movie like this:

    <?php
    // A simple example key:
    $trailer_key = 'G4_ULVw5L04';
    $trailer_url = 'https://www.youtube.com/embed/' . $trailer_key;
    
    // Minimal iframe
    $embed_this = '<iframe src="' . $trailer_url . '"></iframe>';
    ?>
    

About

A minimal working example of creating and authenticating a php GET request to an API, and converting the JSON response to a php object.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages