using php, how do i upload youtube videos on my site using the youtube v3 api?

Riley Java

I am doing this website where the user registers and uploads a video using youtube link. I don't want to use a Youtube Channel. I am new to programming in php and i have no idea as to how to go about this. The page also has to have a category list of the videos on the website after the user uploads a video.

Any help would be appreciated

edit: here is what i got so far, i don't know how i got here, all i know is that it doesn't work. It has a modal which lets the user input the video link and import it to a page that will display all videos.

<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>test 1</title>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <script src="assets/js/jquery.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    </head>
<body>
<div class="col-md-8">
<div class="video-embed-iframe">
<div class="embed-responsive embed-responsive-16by9">
<iframe src="http://www.youtube.com/embed/{$videos_youtube_id}?autoplay={$player_autoplay}&showinfo={$player_showinfo}&rel={$player_related}&controls={$player_controls}&loop={$player_loop}&color={$player_color}" allowfullscreen></iframe>
</div>
</div>



<div class="modal fade" id="upload-modal">
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title"><span class="fa fa-upload"></span> {$lang_upload_new_videos}</h4>
    </div>
    <div class="modal-body">
        <div id="upload-message"></div>
        <form id="upload-form" method="POST" action="">
        <div class="row">
          <div class="col-md-12">
          <div class="form-group">              
            <label for="category">{$lang_category} <span>*</span> </label>
            <select class="form-control" name="category" id="category">
                {section name=x loop=$categories}
                    <option value="{$categories[x].id}">{$categories[x].category}</option>
                {/section}
            </select>
          </div>
          <div class="form-group">
            <label for="link">{$lang_videos_link} <span>*</span> </label>
            <input type="text" class="form-control" name="link" dir="ltr" id="link" placeholder="https://www.youtube.com/watch?v=uJcB3ZaaLlA" />
            <p class="help-block" dir="ltr">youtube video link</p>
          </div>

          </div>
        </div>
        <div class="modal-footer">
            <button type="button" id="import_btn" class="btn btn-inverse pull-left">{$lang_import}</button>
        </div>
        </form>
</div>
</div>
</div>

</body>
</html>
Mark Ryan Orosa

Since you said you are new to PHP as well I suggest you dig in a bit more on the matter.

But this is a working code, that hopefully help you a bit.

if($client->getAccessToken()) {
$snippet = new Google_VideoSnippet();
$snippet->setTitle("Test title");
$snippet->setDescription("Test descrition");
$snippet->setTags(array("tag1","tag2"));
$snippet->setCategoryId("22");

$status = new Google_VideoStatus();
$status->privacyStatus = "private";

$video = new Google_Video();
$video->setSnippet($snippet);
$video->setStatus($status);

$error = true;
$i = 0;

try {
    $obj = $youTubeService->videos->insert("status,snippet", $video,
                                     array("data"=>file_get_contents("video.mp4"), 
                                    "mimeType" => "video/mp4"));
} catch(Google_ServiceException $e) {
    print "Caught Google service Exception ".$e->getCode(). " message is ".$e->getMessage(). " <br>";
    print "Stack trace is ".$e->getTraceAsString();
}

}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I obtain a list of all videos in a channel using the YouTube Data API v3?

From Dev

How to upload Video to YouTube using Google API PHP Client Library and Youtube API V3?

From Dev

How do I get video stats using youtube v3 api in PHP

From Dev

Youtube Related Videos using Youtube V3 API

From Dev

Upload videos to my Youtube channel without user authentication using YoutubeApi v3 and ouath2

From Dev

How to delete a video using the youtube API v3 and PHP

From Dev

Search Videos by keyword using YouTube Data API V3

From Dev

How to mute a Youtube Video by using Youtube API v3?

From Dev

Error when uploading larger videos using Youtube API v3 resumable upload (on AWS EC2)

From Dev

Retrieve all videos from youtube playlist using youtube v3 API

From Dev

Memory leak using official resumable video upload for Youtube PHP API V3

From Dev

.net Youtube api v3 upload videos to an specific account

From Dev

Fetch video details on Youtube using API v3 in PHP

From Dev

Deleting a video using YouTube API v3 PHP

From Java

Determine a YouTube channel's upload rate using YouTube Data API v3

From Dev

Youtube get the videos IDs of user in API v3 PHP

From Dev

Youtube get the videos IDs of user in API v3 PHP

From Dev

youtube api v3 - get videos from a public playlist. with out using api key

From Dev

How can I upload my videos to the recommended encoding settings for YouTube?

From Dev

Get Videos from a Channel using Youtube API V3 in C#

From Dev

Get Videos from a Channel using Youtube API V3 in C#

From Dev

Fetch list of videos from Youtube channels using Youtube API v3 (without the annoying authentication pop-up)

From Dev

Fetch list of videos from Youtube channels using Youtube API v3 (without the annoying authentication pop-up)

From Dev

Unable to delete a youtube playlist using youtube api v3

From Dev

Unable to delete a youtube playlist using youtube api v3

From Dev

How to check if YouTube video exists using YouTube Data API v3

From Dev

how to get full description of youtube video using youtube api v3

From Dev

How to fetch share count of youtube video using YouTube Analytics API v3?

From Dev

how to get full description of youtube video using youtube api v3

Related Related

  1. 1

    How do I obtain a list of all videos in a channel using the YouTube Data API v3?

  2. 2

    How to upload Video to YouTube using Google API PHP Client Library and Youtube API V3?

  3. 3

    How do I get video stats using youtube v3 api in PHP

  4. 4

    Youtube Related Videos using Youtube V3 API

  5. 5

    Upload videos to my Youtube channel without user authentication using YoutubeApi v3 and ouath2

  6. 6

    How to delete a video using the youtube API v3 and PHP

  7. 7

    Search Videos by keyword using YouTube Data API V3

  8. 8

    How to mute a Youtube Video by using Youtube API v3?

  9. 9

    Error when uploading larger videos using Youtube API v3 resumable upload (on AWS EC2)

  10. 10

    Retrieve all videos from youtube playlist using youtube v3 API

  11. 11

    Memory leak using official resumable video upload for Youtube PHP API V3

  12. 12

    .net Youtube api v3 upload videos to an specific account

  13. 13

    Fetch video details on Youtube using API v3 in PHP

  14. 14

    Deleting a video using YouTube API v3 PHP

  15. 15

    Determine a YouTube channel's upload rate using YouTube Data API v3

  16. 16

    Youtube get the videos IDs of user in API v3 PHP

  17. 17

    Youtube get the videos IDs of user in API v3 PHP

  18. 18

    youtube api v3 - get videos from a public playlist. with out using api key

  19. 19

    How can I upload my videos to the recommended encoding settings for YouTube?

  20. 20

    Get Videos from a Channel using Youtube API V3 in C#

  21. 21

    Get Videos from a Channel using Youtube API V3 in C#

  22. 22

    Fetch list of videos from Youtube channels using Youtube API v3 (without the annoying authentication pop-up)

  23. 23

    Fetch list of videos from Youtube channels using Youtube API v3 (without the annoying authentication pop-up)

  24. 24

    Unable to delete a youtube playlist using youtube api v3

  25. 25

    Unable to delete a youtube playlist using youtube api v3

  26. 26

    How to check if YouTube video exists using YouTube Data API v3

  27. 27

    how to get full description of youtube video using youtube api v3

  28. 28

    How to fetch share count of youtube video using YouTube Analytics API v3?

  29. 29

    how to get full description of youtube video using youtube api v3

HotTag

Archive