tags:

views:

44

answers:

2

I load Flash file using PHP.
test.php :

$widget = WidgetFactory::getInstanceByHash($_GET['hash']);  
$file = $widget->getUrl();  
$_GET['param1'] = "97df5ea7342b7e55b7ef3d402b585d1a";  
header("Content-Type: application/x-shockwave-flash");  
readfile($file);

The url of $file is for example : "http://adresse/component1.swf?param1=XXX"
If I type "http://adresse/test.php?hash=XXXXXXXXXXXXX" in my browser, I can see the flash file WITHOUT the parameter param1.
I tried to add : $_GET['param1'] = "97df5ea7342b7e55b7ef3d402b585d1a";
But it doesn't works.

So, I want to know if it is possible to add parameters by using header function...

+1  A: 

A GET parameter is a parameter set by the HTTP_REQUEST but the header() function sets parameters of the HTTP_RESPONSE so there are never GET parameters in the response.

What it the actual problem with your code? How should the result look like?

EDIT: You might try to get the file using file_get_contents() or curl() appending the parameter:

echo file_get_contents($file.'?param1=97df5ea7342b7e55b7ef3d402b585d1a');
Kau-Boy
Actually my problem is that I can't get the parameter **param1** in my **component1.swf** when it is loaded by the php file. One solution is to set the parameter in the attribute flashvar in tag object but I lose in modularity...Thanks for answer
Epharion
Can't you use a rewrite rule to rewrite the hash parameter to the param1 parameter? Or are the two parameters of different values?
Kau-Boy
echo file_get_contents($file.'?param1=97df5ea7342b7e55b7ef3d402b585d1a'); doesn't works. I think, they are no solution to send flashvar by php...
Epharion
Is file a filepath on your server or a URL? How exactly do you try to integrate the flash into your file. Can you provide us a full example?
Kau-Boy
$file is a URL.I have a web page which contains :<object ...> ... <param name="movie" value="http://127.0.0.1/widget.php?hashWidget=7e564vcfdfdf564gecd" /> ... <embed src="http://127.0.0.1/widget.php?hashWidget=7e564vcfdfdf564gecd" ...></embed> </object>widget.php will load the flash based on the parameter **hashWidget**But the flash file is dynamic, I have to pass parameters. In flash we could pass parameter like this : "http://127.0.0.1/flash.swf?param=helloworld". The problem is that the parameter is not passed through widget.php
Epharion
That looks unsolvable for me. I think you need to replace the hash with the actual URL within the src attribute. Or you have to use an iframe in your HTML and then create the object/embed in the iframe using the widget.php script.
Kau-Boy
A: 

I'm not sure I understand what you are trying to say here.

If you try this:

 <?php
 header("Content-Type: application/x-shockwave-flash");
 readfile("http://adresse/component1.swf?param1=97df5ea7342b7e55b7ef3d402b585d1a");
 ?>

Then I expect you will get what you are looking for. $_GET is a parsed copy of the CGI parameters passed in a URL. If you overwrite this in PHP it doesn't change the CGI parameters which were passed to the script. And the CGI parameters passed to the script have nothing to do with the parameters passed in a subsequent HTTP call unless you explicitly include them in the URL.

C.

symcbean