Your syntax is spot on. It's only lacking one crucial thing. Per default  
PHP is sent as text/html so along with the Location header you need to  
send the correct content-type header (to build on your example):

header('Content-type: video/mpg');
header('Location: '.$videos[$_GET['video']]);

And since Mike was writing pseudocode you also need to add your own input  
checking (e.g. throw a 404 if the video isn't found) and so on.

As Mike demonstrated the difficult bit is not sending the headers. It's  
deciding what kind of stats you want to save and then building the  
database scripts to deal with it.

- Andreas

Den 23.01.2007 kl. 14:47 skrev Mike Hudack <[EMAIL PROTECTED]>:

> Hey Bill,
>
> This is indeed pretty easy to do.  We do it for a number of reasons,
> from collecting statistical information to finding the most appropriate
> server to deliver the video from, which means that our code for doing
> this is pretty complicated.  Your code can probably be much simpler.
>
> I'm not really a php programmer (I'm more of a perl guy), but this kind
> of form should work for you assuming you have a call style like
> http://mywebsite.com/video.php?video=bar.mpg:
>
> <?php
>       $videos['foo.mpg'] = 'http://bar.baz/foo.mpg';
>       $videos['bar.mpg'] = 'http://foo.baz/bar.mpg';
>
>       // Do what you want to collect data, et cetera
>
>       header('Location: ' . $videos[$_GET['video']];
> ?>
>
> You should probably consider this pseudo code and not actual code, since
> my recollection of php syntax and variable instantiation is pretty
> rusty.  One thing to keep in mind is that you cannot output anything
> from your php script prior to calling the header() function -- if it
> isn't the first thing you call that produces output your script will
> break with an ugly HTML Web page with a big bold error message in the
> middle of it.
>
> Yours,
>
> Mike
> Co-founder & CEO, blip.tv
>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[EMAIL PROTECTED] On Behalf Of billshackelford
>> Sent: Tuesday, January 23, 2007 12:39 AM
>> To: [email protected]
>> Subject: [videoblogging] Permalinks and download tracking?
>> How do I do that?
>>
>> Blip.tv has permalinks like this:
>>
>> http://blip.tv/file/get/Bshack-PopPopPop659.m4v
>>
>> When you click on it, it will redirect to the actual file
>> location. When it redirects it also gathers information about
>> you for stats. The above link will work in itunes even with
>> the redirects.
>>
>> How do they do that? I could I do that with PHP?
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>



-- 
Andreas Haugstrup Pedersen
<URL: http://www.solitude.dk/ >

Reply via email to