mardi 4 août 2015

youtube v3 api, check if Video existing

I've tried to check if a youtube video is online, not private, not deleted etc. I need it for a Video-Blog.

All of the code I've found and tried hadn't worked. I hope you can help me. I've registered for the new API v3.

My code is as follows, but I always get "Bad Request 400"

$theURL = "http://ift.tt/1eQdIk1". get_post_meta($post->ID,"wpzoom_post_embed_code", true) ."&key=my_api_key";
//                echo $theURL;
                //$theURL = "http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=". get_post_meta($post->ID,"wpzoom_post_embed_code", true) ."&format=json";
                $headers = get_headers($theURL);
                print_r ($headers);
                if (substr($headers[0], 9, 3) !== "404") {
                    echo "online";
                } else {
                    echo "offline";
                }  



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire