I have one Youtube Channel with about six subchannels.
How can i define the Channel in the API which i like to Upload a Video to
Something like:
<?php
$snippet->setChannelId("UCYr0l3qoK7cuZynbvDYl7Q");
?>
Check the ChannelSection with the type multipleChannels. As stated in this post, using this method, you were able to:
Pull a list of all channelSections
Find the id of the channelSection whose type is multipleChannels and title is Music Genres (as example).
Using the ID from step 2 you can now Query that specific channelSection
There's no such thing as sub-channels in YouTube. What you probably mean is that you have one Google account that manages multiple individual channels.
When you upload a video, your application will go through the process of obtaining OAuth tokens from the API server. This is where a user action is required: The user gets directed to a webpage on which he can give his permission that the app may access his channel. If a Google account manages multiple channels, the user must select one. The tokens which your app receives as a result of this process are tied to the channel that the user selected and cannot be used to upload to other channels.
These tokens can then be used by your application to perform API requests like uploading videos.
Related
I'm creating an app to show all the Google Photos albums of an account (like a gallery) and I want everyone to be able to access the album via a link. I create the albums directly in Google Photos and make them public (creating a sharing link).
I already set up the authentication via Oauth2.0 and created a photosLibraryClient. I am able to get all the albums, their ID's, their names, their cover photo, ... But I can just get it's link but not the shareable one (the public).
I read about the sharing options in the API documentation: https://developers.google.com/photos/library/guides/share-media
But, as far as I undertood, you can only retrieve a sharing Url if you created the album via the app.
I'm listing albums like this:
$photosLibraryClient->listAlbums()
I'm not sure if there is any accessible attribute or method that I don't know here...
I also tried to access the ShareInfo:
$albumUrl = $photosLibraryClient->shareAlbum($album->getId())->getShareInfo()->getShareableUrl();
But i get the error:
NO PERMISSION TO SHARE THIS ALBUM SINCE IT WAS NOT CREATED BY THIS APP
Any ideas on what to do?
It's not possible. In the Google Issue Tracker there's a couple of people asking for this same feature. One issue it's still marked as new though it's from 2019. The other one is closed due to "intended behaviour".
We'll have to wait until more people wants this feature or people at Google decide to make it available. Until then, I'll have to manually add a new record to a DB (with a table made for this single purpose) everytime I upload a new album...
I have requirement where I need to provide ui to my website users to upload video's on one common channel , Can anyone know, how can I implement it ?
I googled on it but get no result
I know all about You tube Data Api v3 and implemented it, but don't know how to implement it for my website such that all users can add their videos on my own channel.
I get blocked at authentication page because after login each user can add video on their own channel
What you want to do is only possible with YouTube Direct Lite. Basically user's will upload to their own channel but videos will be submitted to your playlist.
I have a website on which clients will be uploading videos. The thing is - I want those videos to be uploaded to OUR channel, not users' channels. I don't see how I could make it work using YouTube API v3.
Every time a person wants to upload something using the access token I provided he has to input his own credentials. He can't simply upload anything directly to OUR channel.
Is there a way to work that around?
Short answer is: You should not ask your users to upload into your account.
But please read further:
https://stackoverflow.com/a/12626209/1973552
https://stackoverflow.com/a/15258781/1973552
Api V2 have option you've mentioned. Did you try it?
Basically you want to let Users upload Videos in your website, but upload them directly to youtube, without Google AUTH?
Yes you can. Make sure you set the setAccessType to offline.
$client->setAccessType("offline");
This will make it so you get a refresh Token with the users account authentication the first time. A refresh token allows you to reauthenticate without the user being present. (aka, offline). Create your script from the sample API v3 scripts, authorize your main account (the one you want to be predetermined) and display the response. Something like the following will show you your response:
print_r($client->getAccessToken());
You will see your refresh Token in the json response. Save that (either to a database, or hard code it into the script). Now that you have a refresh token, whenever you want to upload to youtube, just call
$client->refreshToken($THE_REFRESH_TOKEN_YOU_SAVED);
$thetoken = $client->getAccessToken();
$client->setAccessToken($thetoken);
After this, your previously authenticated account will now be currently logged into your script.
FYI, these are php examples, you might need to adjust accordingly.
I'm tryin to develop a (almost) 100% client-side dynamic website by integrating it with twitter, facebook and flickr.
I've been able so far to get the last 4 tweets (with javascript) from my client's feed, and now i was wandering if i could do the same with facebook's gallery and events from their feed.
Especially, what i need (given the facebook username/api key/whatever)
gallery
for each gallery in user's profile:
get the gallery name
get the first picture
get the gallery url
news/events
for each news/event/post in user's profile:
get the event name
get the event text
get the event picture (if provided)
get the event url
I don't want to use the facebook widgets with their rendering, i just need to read the json response (if there's any) and put the data inside my website (like a preview).
Since my client is pretty rusty with "computers (cit.)" but he's (not so strangely) comfortable with facebook/twitter/flickr, i tought about a solution like this before adding a database and an admin interface to our website.
I found some resources online, so i think it's possible (in a way or another). I'd like to do it in javascript, but if it's php i won't complain.
Check out this API to get photoes from the user profile
http://developers.facebook.com/docs/reference/api/album/
This is for events
http://developers.facebook.com/docs/reference/api/event/
You can use either the PHP or the Javascript API SDKs:
http://developers.facebook.com/docs/reference/php/
http://developers.facebook.com/docs/reference/javascript/
respectively. Naturally you would handle the returned information differently. Both have a method called api() which can be utilised to grab the album and event objects (as mentioned in another answer):
http://developers.facebook.com/docs/reference/api/album/
http://developers.facebook.com/docs/reference/api/event/
You can pass parameters in the methods to restrict the results returned by fields, number of items, sizes of images etc. This is outlined here:
http://developers.facebook.com/docs/reference/api/
But the issues you are going to face is that you have to authorise your "app" - think website when they use the terminology "app" - to give it permissions to access the information. This takes the form of a two step process. You have to create the app on the Facebook platform which can then access the API methods (only certain information can be got from the API methods without an authenticated app).
The second part is that the user themselves must then authenticate their facebook account against your app - this gives your app permission to access the user's information. In plain English it would go like this:
User visits your webpage; user must be logged into Facebook and must approve your app (this used to be called Facebook Connect for obvious reasons); the app and the user account are "connected"; the app can then use the api methods you've written to return information about the connected user
The beginning explanations of how to do this are here:
http://developers.facebook.com/docs/authentication/
The only way you can access a user's (non-public) information from outside of Facebook is via a connected app and user profile.
I have a site and I want to upload videos onto YouTube without a login. Is it possibe? If yes, how can do this?
Create an account and use its credentials all the time, for all users of your site. You simply can't upload a video without a user account 'responsible' for it. #Pekka: ask for forgiveness, not for permission? ;)
Google at least has a youtube API (with uploading capabilities and PHP examples) right here: http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Uploading_Videos
It is not possible to upload Video to YouTube without logging in.
That said, I wouldn't be surprised if even automated uploading with a login would be forbidden by YouTube's Terms and Conditions.
There is a way to do that without zend client library. Its in core php (PHP4).
https://github.com/techie28/YouTubeUploadPHP.
Note: AuthSub is deprecated now.Please refer to Google Deprecated policy for details.
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).
This tutorial describes the direct browser based upload technique using AuthSub.
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.
We will go through the way to upload a video using AuthSub.
It goes as follows and can be really done in following 4 simple steps:
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
and again curl has business to do you will upload this by issuing another curl call:
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.
The github link for the Sample code is here.