Question

I am developing code using the youtube API for live streaming. What I have done

  1. I have registered a project in google and gotten client_id, client_secret, and developer ID
  2. I have done OAuth 2.0 and gotten the code and exchanged it to AUTH_TOKEN
  3. I can create a live event by posting to domain gdata.youtube.com

with request

/feeds/api/users/default/live/events

with header

Authorization: Bearer AUTH_TOKEN
GData-Version: 2
Content-Type: application/atom+xml
X-GData-Key: key=DEV_ID

with content

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
  xmlns:media='http://search.yahoo.com/mrss/'
  xmlns:yt='http://gdata.youtube.com/schemas/2007'> 
  <title>Test</title> 
  <summary>Test gogogogo!</summary>
  <content type='application/atom+xml'>
    <entry>
      <yt:private/> 
      <yt:cdn name='primary'>
        <media:content yt:format='18'/> 
        <media:content yt:format='19'/> 
      </yt:cdn> 
    </entry> 
  </content> 
  <yt:when start='2013-07-05T22:00:00.000Z'/> 
</entry>

This returns HTTP code : 201 and my live event is created, but the returned data does not include STREAM KEY AND RTMP URL. I need these data to start my live event automatically.

the return data

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
  xmlns:app='http://www.w3.org/2007/app'
  xmlns:media='http://search.yahoo.com/mrss/'
  xmlns:gd='http://schemas.google.com/g/2005'
  xmlns:yt='http://gdata.youtube.com/schemas/2007'
  gd:etag='W/&quot;CkEHR347eCp7I2A9WhFQEE0.&quot;'>
  <id>tag:youtube.com,2008:live:event:XXXXXXXXXXXXXXXXXXXX</id>
  <published>2013-07-05T05:03:56.000Z</published>
  <updated>2013-07-05T05:03:56.000Z</updated>
  <app:edited>2013-07-05T05:03:56.000Z</app:edited>
  <category scheme='http://schemas.google.com/g/2005#kind'
    term='http://gdata.youtube.com/schemas/2007#liveEvent'/>
  <title>Test</title>
  <summary>Test gogogogo!</summary>
  <content type='application/atom+xml'
    src='http://gdata.youtube.com/feeds/api/users/XXXXXXX/live/videos/XXXXXXXXX'/>
  <link rel='self' type='application/atom+xml'
    href='http://gdata.youtube.com/feeds/api/users/XXXXXXXXXXXXXXX/live/events/XXXXXXXXXXXXXXXXXX'/>
  <link rel='edit' type='application/atom+xml'
    href='http://gdata.youtube.com/feeds/api/users/XXXXXX/live/events/XXXXXXXXXXXXXXXXXXXXXX'/>
  <author>
    <name>XXXXXX</name>
    <uri>http://gdata.youtube.com/feeds/api/users/XXXXXXXXXX</uri>
    <yt:userId>XXXXXXXXXXXXX</yt:userId>
  </author>
  <media:group>
    <media:description type='plain'>Test gogogogo!</media:description>
    <media:title type='plain'>Test</media:title>
  </media:group>
  <yt:status>pending</yt:status>
  <yt:when start='2013-07-05T22:00:00.000Z'/>
</entry>

If I manually login youtube and click on my create live event, I can see my stream key and RTMP URL there. And I can use they to start streaming manually So my problem is: how can I get STREAM KEY and RTMP URL automatically (by API request)?

----EDIT----

based on https://developers.google.com/youtube/2.0/developers_guide_protocol_managing_live_events

it said that when I success create/adding an event, youtube will returns url like this

  <yt:cdn name='primary'>
    <media:content yt:format='19' yt:name='yt-live_SpQXZYILnN0_35'
        url='rtmp://rtmp1.youtube.com/videolive?...'/>
  </yt:cdn>

but in my case, my returned data doesn't include this line

Was it helpful?

Solution

After do some research, I solved it by sending this request

/feeds/api/users/default/live/events?inline=true

and the youtube returns me RTMP server URL

Thanks all

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top