PHP calls Youku video details through ajax + curl + Open API

Source: Internet
Author: User
Youku open API: Youku

Youku open API: http://v.youku.com/player/getplaylist/videoids/video ID

For example, in the browser address bar, enter the video ID XNjI0NDMxNDc2.

Http://v.youku.com/player/getPlayList/VideoIDS/XNjI0NDMxNDc2

The returned result data in json format is as follows (partial, incomplete ):

VidEncoded is the encoded video ID. In this example, XNjI0NDMxNDc2 is used;

The logo is a video, the title is the video title, the tags is the video tag, and the seconds is the video duration.

 

The implementation of this case is as follows:

1. enter the URL of a video, bind a click event to the search button, and call ajax;

2. transmit the video url to the backend using ajax, parse the video id in the url through the regular expression in the PHP background, and call the open API using curl to obtain the returned json data;

3. splice the json data returned from the background into the video playback code and display it in the corresponding div.

?

Code implementation:

Front-end code youku. php:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.