Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3343956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:00:51+00:00 2026-05-18T01:00:51+00:00

In the messages users write with eachother, I wish to turn Youtube links into

  • 0

In the messages users write with eachother, I wish to turn Youtube links into the youtube thumbnail of it+title.

So how can I check if $msg contains a youtube video link, and if it does, it should take the video id (?v=) of it, and run this:

$.getScript( 'http://gdata.youtube.com/feeds/api/videos/$videoid?v=2&alt=json-in-script&callback=youtubeFetchDataCallback' );

How can this be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:00:51+00:00Added an answer on May 18, 2026 at 1:00 am

    Already resolved partially here: parse youtube video id using preg_match

    EDIT alternatively you could use parse_url() in PHP check the host is youtube and if it is read the query string and split into key/value pairs and read the “v” value

    EDIT 2

    <?php
    $url = "http://www.youtube.com/watch?v=QDe6MZQjpho";
    $url = parse_url($url);
    if($url['host'] == "www.youtube.com") {
        parse_str($url['query'], $output);
        $videoID = $output['v'];
    } else {
        echo "not youtube.com";
    }
    ?>
    

    EDIT 3 Another way

    <?php
    $url = "http://www.youtube.com/watch?v=QDe6MZQjpho";
    if(preg_match("#http://(.*)\.youtube\.com/watch\?v=(.*)(&(.*))?#", $url, $matches)){
        $videoID = $matches[2];
    } else {
        echo "not youtube.com";
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Rails 3 application users can write messages/posts in forum. I would like
I want to write an application using Java6 that can check a users Hotmail
I have a database of users where they can send messages to other users
how can I show users success/error messages without creating a node for it? Thanks
I have a table known as messages . In my application, users can send
So I'm trying to write messages from users on a messaging network to a
Let's say i have two Doctrine entities: Users and Messages Every user can have
I have a simple table maintaining messages between users. The table structure looks like
I'd like to avoid this scary messages when users install my application: I understand
When I acesss http://example.com/users/1/messages/new it says undefined method `error_message_on' for #<#<Class:0x00000005921d50>:0x0000000591e448> If I delete

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.