2012-09-01 29 views
6

我正在使用embedly,它工作正常,但問題是某些視頻給出了錯誤 - 我知道我們必須在他們的網站上註冊並支付一些鑰匙費用,我不想這樣做。是否有任何其他解決方案爲視頻嵌入代碼,這樣我就可以嵌入我的代碼,而不是嵌入。如果是,請在此幫助我,或者如果可能,請提供一些示例來執行此操作。下面給出了密鑰的代碼。如何獲得視頻的嵌入代碼

$pro = new Embedly_API(array(
    'key' => 'xxxxxxxxxxxxxxxx', //need a pro key for this 
    'user_agent' => 'Mozilla/5.0 (compatible; mytestapp/1.0)' 
)); 

在此先感謝。

+0

http://oembed.com/ – hakre

回答

1

你不需要需要來支付任何金錢的光使用。

你應該嘗試的定價頁面上向下滾動:http://embed.ly/pricing

然後選擇免費選項。

1

我已經爲您的問題構建了腳本的編碼,請根據您的需要找到下面的代碼並使用它。

<!DOCTYPE> 
<html> 
    <head> 
    <title>Page Title</title> 
    <script src="http://code.jquery.com/jquery-1.4.4.min.js"></script> 
    <script type="text/javascript"> 
     /* 
* Embedly JQuery v2.2.0 
* ============== 
* This library allows you to easily embed objects on any page. 
*/ 
(function(a){window.embedlyURLre=/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;a.embedly=a.embedly||{};if(a.embedly.version){return}a.extend({embedly:function(k,q,n){var c=[];var p="http://api.embed.ly/";var d;q=q?q:{};d=a.extend({},a.embedly.defaults,q);if(!d.urlRe){d.urlRe=window.embedlyURLre}if(typeof k==="string"){k=new Array(k)}if(typeof n!=="undefined"){d.success=n}if(d.secure){p="https://api.embed.ly/"}if(!d.success){d.success=function(i,t){var r,s=a(t.node);if(!(i)){return null}if((r=d.method)==="replace"){return s.replaceWith(i.code)}else{if(r==="after"){return s.after(i.code)}else{if(r==="afterParent"){return s.parent().after(i.code)}else{if(r==="replaceParent"){return s.parent().replaceWith(i.code)}}}}}}if(!d.error){d.error=function(i,r){}}var m=function(i){return d.urlRe.test(i)};var o=function(r){var i="urls="+r;if(d.maxWidth){i+="&maxwidth="+d.maxWidth}else{if(typeof dimensions!=="undefined"){i+="&maxwidth="+dimensions.width}}if(d.maxHeight){i+="&maxheight="+d.maxHeight}if(d.chars){i+="&chars="+d.chars}if(d.words){i+="&words="+d.words}if(d.secure){i+="&secure=true"}if(d.frame){i+="&frame=true"}i+="&wmode="+d.wmode;if(typeof d.autoplay==="string"||typeof d.autoplay==="boolean"){i+="&autoplay="+d.autoplay}if(d.width){i+="&width="+d.width}return i};var j=function(){if(typeof d.autoplay==="string"){if(d.endpoint.search(/objectify/i)>=0){return p+"2/objectify"}else{if(d.endpoint.search(/preview/i)>=0){return p+"1/preview"}}}return p+"1/oembed"};var b=function(){var i=[];if(d.addImageStyles){if(d.maxWidth){units=isNaN(parseInt(d.maxWidth,10))?"":"px";i.push("max-width: "+(d.maxWidth)+units)}if(d.maxHeight){units=isNaN(parseInt(d.maxHeight,10))?"":"px";i.push("max-height: "+(d.maxHeight)+units)}}return i.join(";")};var g=function(v,t){if(d.endpoint!=="oembed"){return d.success(v,t)}var w,s,r,y,u,i,x,z;if((w=v.type)==="photo"){y=v.title||"";s="<a href='"+t.url+"' target='_blank'><img style='"+b()+"' src='"+v.url+"' alt='"+y+"' /></a>"}else{if(w==="video"){s=v.html}else{if(w==="rich"){s=v.html}else{y=v.title||t.url;i=v.thumbnail_url?"<img src='"+v.thumbnail_url+"' class='thumb' style='"+b()+"'/>":"";z=v.description?'<div class="description">'+v.description+"</div>":"";x=v.provider_name?"<a href='"+v.provider_url+"' class='provider'>"+v.provider_name+"</a>":"";s=i+"<a href='"+t.url+"'>"+y+"</a>";s+=x;s+=z}}}if(d.wrapElement&&d.wrapElement==="div"&&a.browser.msie&&a.browser.version<9){d.wrapElement="span"}if(d.wrapElement){s="<"+d.wrapElement+' class="'+d.className+'">'+s+"</"+d.wrapElement+">"}v.code=s;if(typeof t.node!=="undefined"){a(t.node).data("oembed",v).trigger("embedly-oembed",[v])}return d.success(v,t)};var e=function(i){var t,v,u,s,r;u=a.map(i,function(x,w){if(w===0){if(x.node!==null){r=a(x.node);s={width:r.parent().width(),height:r.parent().height()}}}return encodeURIComponent(x.url)}).join(",");a.ajax({url:j(),dataType:"jsonp",data:o(u),success:function(w){return a.each(w,function(x,y){return y.type!=="error"?g(y,i[x]):d.error(i[x].node,y)})}})};a.each(k,function(s,r){var u=typeof d.elems!=="undefined"?d.elems[s]:null;if(typeof u!=="undefined"&&!m(r)){a(u).data("oembed",false)}var t={url:r,error_code:400,error_message:"HTTP 400: Bad Request",type:"error"};return(r&&m(r))?c.push({url:r,node:u}):d.error(u,t)});var l=[];var h=c.length;for(var f=0;(0<=h?f<h:f>h);f+=20){l=l.concat(e(c.slice(f,f+20)))}if(d.elems){return d.elems}else{return this}}});a.embedly.version="2.2.0";a.embedly.defaults={endpoint:"oembed",secure:false,frame:false,wmode:"opaque",method:"replace",addImageStyles:true,wrapElement:"div",className:"embed",elems:[]};a.fn.embedly=function(d,g){var e=typeof d!=="undefined"?d:{};if(typeof g!=="undefined"){d.success=g}var f=new Array();var c=new Array();this.each(function(){if(typeof a(this).attr("href")!=="undefined"){f.push(a(this).attr("href"));c.push(a(this))}else{a(this).find("a").each(function(){f.push(a(this).attr("href"));c.push(a(this))})}e.elems=c});var b=a.embedly(f,e);return this}})(jQuery); 

     </script> 
    <script type="text/javascript"> 
     $('document').ready(function(){ 
     $('div.content').embedly({ 
      maxWidth: 450, 
      wmode: 'transparent', 
      method: 'after'  
     }); 
     }); 
    </script> 
    </head> 
    <body> 
    <div class="content"> 
     <article> 
     <h2>Title</h2> 
     <p>Lorizzle ma nizzle dolor sit amizzle, brizzle adipiscing elit. </p> 
     <a href="http://www.youtube.com/watch?v=ZbcgyPtYBY0">youtube</a> 
     <p>Maecenizzle owned bow wow wow. Nam eros.</p> 
     </article> 
     <article> 
     <h2>Title 2</h2> 
     <p>Lorizzle ma nizzle dolor sit amizzle, brizzle adipiscing elit. </p> 
     <a href="http://www.flickr.com/photos/churchclothing/2597225382/">flickr</a> 
     <p>Maecenizzle owned bow wow wow. Nam eros.</p> 
     </article> 
    </div> 
    </body> 
</html> 

它工作正常,測試它並根據您的意願使用它。

+0

謝謝@約翰彼得,但正如我所說,它沒有得到所有的視頻 - 例如:http://www.wimp.com/puntreturn/。我不知道爲什麼這不起作用,如果你知道你能解釋我嗎? –

+0

請參考以下位置的原因: http://embed.ly/docs/explore/oembed?url=icheb.wimp.com%2Floadvideo%2Fcd223b51d556b1e274b606b8dbd0c352%2F5055a5dd%2Fweb-videos%2F0cfb6bf8e8bbd5abe051661594e7c59f_photo.flv –

+0

所以是有任何方式從所有的網站獲得視頻,因爲embeldly不支持所有的視頻網站?其實我從2周開始嘗試,仍然沒有解決辦法,可以請幫助我。 –

相關問題