Zend-çerçeve: YouTube video bağlantısı doğrulama

2 Cevap php

Zend-çerçeve ile Youtube video bağlantısını doğrulamak için herhangi bir yöntem mi?

Kullanıcının geçerli bağlantı, örneğin, http://www.youtube.com/watch?00zzv=nel nasıl site içine yerleştirmeden önce kontrol edebilirsiniz değilse?

2 Cevap

Ben bunun için doğrulayıcısındaki orada inşa olduğundan eminim, ama özel denetleyiciler yazma süper kolaydır:

class My_Validate_Youtube extends Zend_Validate_Abstract{

    public function isValid($value){
        // check url here
        if (no_good($value)){
            $this->_error("Explain the error here");
            return false;
        }
        return true;
    }

}

Sadece o sınıfta ihtiyaç denetler ne koymak ve kontrol edilecek herhangi bir Youtube bağlantıları validator çalıştırın.

edit: From Laykes, you might want to consider using the validator to check if the video actually exists, instead of determining if it fits a pattern. Depends on your use cases though- eg how much latency do you want to introduce by making a call to the Youtube API?

Ben eğer mümkünse, ancak ben farklı bir yaklaşım almak ve denemek ve bağlantı üzerinde yorum var olmadığını görmek istiyorsunuz bilmiyorum.

Take this for example. From here: http://framework.zend.com/manual/en/zend.gdata.youtube.html

$yt = new Zend_Gdata_YouTube();
$commentFeed = $yt->getVideoCommentFeed('abc123813abc');

foreach ($commentFeed as $commentEntry) {
    echo $commentEntry->title->text . "\n";
    echo $commentEntry->content->text . "\n\n\n";
}

Eğer VideoCommentFeed argüman video kimliği kullanırsanız, $ commentFeed değerini almak mümkün olacak. Eğer bir hata alırsanız, görüntü yok biliyorum.

Ben diğer yöntemleri deneyebilirsiniz eğer muhtemelen ne istediğinizi örnek bulacaksınız eminim.