Web Analytics Made Easy -
StatCounter Problem with headers - CodingForum

Announcement

Collapse
No announcement yet.

Problem with headers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with headers

    Hi there,
    I have a YouTube download script that downloads the youtube flv when the youtube video url is inserted.
    So for example if I run it on my localhost server it will be like http://localhost/youtube.php?url=htt...?v=qsaXzP4V1r8
    On my localhost server, when that url is accessed it will pop-up a download window asking either to open or save. Which is what
    PHP Code:
    header ("Location: $youtubeVideoPath"); 
    is doing.
    The problem is, when I run it on my site and I try to access the url http://domain.com/youtube.php?url=ht...?v=qsaXzP4V1r8 I dont get the download window, in fact only the url in the address bar automatically changes to http://www.youtube.com/get_video.php...Gb_8%3D&fmt=18

    Please let me know what Im missing out here. With a localhost url it works fine and download window pops up, with a domain it doesn't.

    Thanks

  • #2
    Try do add following information to force browser to show save file dialog:

    PHP Code:
    header('Status: 200 OK');
    header('Content-Disposition: attachment; filename="bestyoutube.flv"');
    header('Content-Type: video/flv'); 
    I am not sure what Content-Type you have to use, try video/flv...

    Comment


    • #3
      Thanks PHP6,

      But that didnt help as well.
      Anyone else with any idea?

      Comment


      • #4
        If you check the headers returned by your request, you will find you are actually forwarded on to another URI for the download.

        Implement a loop checking each request for the 'Location: ' header, when you stop receiving this header, then try and download the flv using the last known URI.
        Twitter: @AnthonySterling

        Comment


        • #5
          Originally posted by SilverBulletUK View Post
          If you check the headers returned by your request, you will find you are actually forwarded on to another URI for the download.
          Now I have a question how do you manage to get that information? The links which topic starter posted here was local (localhost) or sample (domain.com) URLs... so how do you know that he is sending couple of locations in header instead of one?

          Comment


          • #6
            The user isn't sending any headers, YouTube are.

            The OP is attempting to download a YouTube video as detailed in this post here, as such, the URI created is forwarded (Using standard HTTP) to a caching server hosted by Google.

            So any attempt to force the download of the original URI will result in a 0 byte FLV.

            You need the follow the headers to completion then force.
            Twitter: @AnthonySterling

            Comment


            • #7
              Originally posted by SilverBulletUK View Post
              The user isn't sending any headers, YouTube are.

              The OP is attempting to download a YouTube video as detailed in this post here, as such, the URI created is forwarded (Using standard HTTP) to a caching server hosted by Google.

              So any attempt to force the download of the original URI will result in a 0 byte FLV.

              You need the follow the headers to completion then force.
              Now I see I have no idea about that URL and method... I was expecting that topic starter is downloading that movie first to his server (in buffer) and only after that outputting the whole buffer with some header information to the user. BUT actually he is just extracting the URL and sending it with header value

              Thanks a lot for your replay

              Comment

              Working...
              X