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

  • Home
  • SEARCH
  • 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 8225819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:32:40+00:00 2026-06-07T15:32:40+00:00

I am using php and yt API to determine if a video exists. I

  • 0

I am using php and yt API to determine if a video exists. I have implemented two functions two help me along this cause. The issues is with the function isYoutubeVideo is returning me null value when a video is valid or invalid. I have checked its paremeters but I am still not sure why is giving me null value. Do i have the isYoutubeVideo function set up wrong/missing something/needs change?

        function isYoutubeVideo($formatted_url) {
            $isValid = false;
            if (isValidURL($formatted_url)) {
                $idLength = 11;
                $idStarts = strpos($formatted_url, "?v=");
                if ($idStarts === FALSE) {
                    $idStarts = strpos($formatted_url, "&v=");
                }
                if ($idStarts !== FALSE) {
                    //there is a videoID present, now validate it
                    $v = substr($formatted_url, $idStarts, $idLength);
                    $headers = get_headers('http://gdata.youtube.com/feeds/api/videos/' . $videoID);
                    //did the request return a http code of 2xx?
                    if (!strpos($headers[0], '200')) {
                        $isValid = true;
                    }
                }
            }
            return $isValid;
  • 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-06-07T15:32:42+00:00Added an answer on June 7, 2026 at 3:32 pm

    Why aren’t your first two echo statements also echoing <span id="resultval"> ?;

    With the current markup and jQuery code this is why jQuery populates #special with null.

    You need to change you PHP code to:

    echo('<div id="special"><span id="resultval">The YouTube video does not exist.</span></div>');
    
    echo('<div id="special"><span id="resultval">that is a valid youtube video</span></div>');
    

    Although, I do not understand why you used such a roundabout way to populate #special. You could have just started with a <p> inside <div id="#special"> and then use the selector $("#special > p")

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using PHP API posts ' likes comes in this detailed format [likes] =>
implementing publishActivity in PHP using the REST API using this code: $activity = array(
I am creating an API using PHP and MongoDB. In this system I got
I'm using PHP to access the Wikipedia API. This is the URL I'm getting:
I am using facebook php api for fetching data. Please help me on how
I have an app using PHP and the PayPal API. The basic way it
I have an iPhone app that is using my PHP API on the server
I'm trying to upload a video to YouTube using the PHP Data API $yt
I need to download Gmail emails using php api. there APIs for google. i
I'm using a rest-api using php. Can someone tell me how to represent the

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.