Ben bir site var ve ben bir giriş olmadan YouTube üzerine video yüklemek istiyorum. Bu possibe mı? Eğer evet ise, nasıl yapabilirim?
There is a way to do that without zend client library. Its in core php (PHP4).
https://github.com/techie28/YouTubeUploadPHP.
Not: AuthSub ayrıntılar için Google Deprecated politikasına bakın now.Please önerilmiyor.
EDIT:
Because codershelpingcoders.com now points to godaddy's parking page and the original link zendtutorials.wordpress.com has an empty article linking to codershelpingcoders.com, I found the original article via the archive: http://web.archive.org/web/20130123044500/http://codershelpingcoders.com/ and have tried to replicate it's contents in this answer for future reference (NOTE: I have no idea if this info still works).
Bu öğretici AuthSub kullanılarak doğrudan tarayıcı tabanlı yükleme teknik anlatılmaktadır.
AuthSub is the Authorization module of the YouTube that lets your application interact with the YouTube for specific purposes such as Uploading videos etc on user’s behalf.
It is same like Auth and a cousin of oAuth.
A user grants the privilege to your site application and you can do the job on his behalf as simple as that.
Biz AuthSub kullanarak bir video yüklemek için yoldan gidecek.
Izler ve gerçekten 4 basit adımı izleyerek yapılabilir gibi gider:
To allow the application run on user behalf a user must have
authorized it first.
So our first step to implement is to get the app Authorized by the user.
We do it by simply redirecting user to the authorization page the url
is as follows:
$nextUrl = urlencode(‘http://www.xxxx.com’) $scope = urlencode(‘http://gdata.youtube.com’); https://www.google.com/accounts/AuthSubRequest?next=’.$nextUrl.’&scope=’.$scope.’&session=1&secure=0
The nextUrl here is the url of the your application where the user
will be redirected after authorization procedure.
scope is to tell the YouTube about the scope of the process which is google
data youtube in this case.
So if user has not authorized your app yet he must be redirected to
the above mentioned authorization page once the user has approved
your application it needs not to follow the step one ever again until
and unless the user revokes the access to you app from the users
control panel of his account.
On successful completion of the authorization process user will be
redirected to your application and this complete the first step of
AuthSub.
If from the first step the user authenticates your application
YouTube will redirect him back to your application with a token in the url.
You are going to use this token and here is where the actual AuthSub process
comes into play you are going to use this token to obtain an entity called
AuthSubSessionToken which will allow you to interact your app to YouTube
on the user behalf who has just approved your application.
In PHP you do it by issuing a curl request. The details are as follows:
Issue a curl GET request to https://www.google.com/accounts/AuthSubSessionToken
with the token you received just after the authorization step.
Remember to turn ON the curl’s response gathering status as you gonna need that.
If everything went well till now you would be responded from YouTube with
the AuthSubSessionToken.
BINGO :-)
Now when you have received the AuthSubSessionToken you are gonna use that to get an upload token which will actually upload the data related to your video to YouTube i.e.title,description,category and keywords. This is kinda reverse process as in AuthSub you upload the data related to the video to YouTube first and then upload the video itself. The uploading of video data also referred as MetaData will be done by feeding XML to the YouTube,the xml will be:
title goes here description goes here category goes here Keyword goes here
ve yine kıvırmak başka kıvırmak çağrı yayımlayarak bu upload edecek yapmak için iş var:
url:http://gdata.youtube.com/action/GetUploadToken headers:AuthSub token=”Your AuthSubSession token goes here” GData-Version:2 ‘X-GData-Key: key=”Your Api key goes here” Content-length: length of the xml you formed above goes here Content-Type:application/atom+xml; charset=UTF-8 POSTFIELDS: the xml itself that you formed
If the step 3 completes successfully then its time to upload the
video actually on your successful last curl execution you will be
reverted back by the YouTube with a url an a token.
Now you will create a form which will have this url as its action and token
as a hidden field something like this.
Just select the video and click submit and your video will get uploaded.
On successful submission you will be redirected back with status 200.
Örnek kod için github link here.