O'Reilly logo

PHP 5 Social Networking by Michael Peacock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Video (via YouTube)

To support video (via YouTube), we need one additional field on the form for the user to paste in the YouTube URL. From the URL, we can automatically generate code to play the video, and we can also look up the thumbnail image of the video from YouTube, from the data contained within the URL.

Database

As with our image's status type, we only require two fields in our new table:

Field

Type

Description

ID

Integer, Primary key

To relate to the main statuses table

Video_id

Varchar

The YouTube video ID

Model

The model needs to be very similar to our image's model. Firstly, the class extends the status class. Then, we have our variable for the video ID, after which we construct the object by calling the parent object's setTypeReference ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required