Hi, i know youtube does not really have an API as such like FB does, and thats why this is being so difficult.
i have a youtube channel and i am looking for a way to give subscribers to the channel some free gifts on my website. i am looking for a way that my website can know of new subscribers to the channel or if youtube can send some kind of http request to my website when anyone subscribes with the channel?

Does anyone know of a way i can achieve this?

As you wrote this is not simple. Yours is a requested feature, check this link: http://code.google.com/p/gdata-issues/issues/detail?id=300
If users submit their own YouTube username on your website, you could use the API to check each single user subscriptions:

- http://code.google.com/apis/youtube/2.0/developers_guide_protocol_subscriptions.html#Retrieving_subscriptions

Or you could just make a list of subscribers from this link:

http://www.youtube.com/profile?user=USERNAME&view=subscribers&start=0

where USERNAME is your Channel username. You don't need to be logged. From there you can:

1) parse the page with file_get_contents() or cURL and PHP DOM
2) go through the pages, if you need to retrieve full listing, start=0 is the first page, start=40 the second and so on

First page gives you the newest subscribers. On the top of the page there's a total count of the subscribers. So, once you have an index stored on your database, your script could just read the total number of subscribers, when needed, and check if the first page list is changed.

Or you can parse YouTube Service mail that you receive for each subscription. You will receive subscriber's username.

These are just few raw ideas, maybe someone else will come with better solutions. Bye :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.