Using the Zend Framework with MySpace
*** THIS ISSUE HAS NOW BEEN RESOLVED BY MYSPACE AND THIS FIX IS NO LONGER REQUIRED ***
There appears to be an issue with the MySpace OpenSocial platform communicating with sites that run the Zend Framework. This error causes the Framework to call the wrong controller - typically this wrong controller is called "relay.proxy".
For example: Using makeRequest() to fetch the page http://www.myZendFrameworkSite.com/index/action will cause the error "relay.proxy is not a valid controller" - this is becuase Zend is reforming the URL as
http://www.myZendFrameworkSite.com/relayproxy.
The reason for this error is that MySpace makeRequest() passes the HTTP_X_REWRITE_URL header directive which is set to something like /relay.proxy?open_social=2325245... Zend sees this header and redirects to http://www.myZendFrameworkSite.com/relay.proxy?open_social=2325245... this then is causing the incorrect controller to be called.
To see this you need to echo the headers from the makeRequest().
To do this:
- Create a Zend Framework site
- Create a controller called RelayProxyController
- Create a view folder called relay-proxy and the normal index.phtml
- In the controller (or the view) enter the code:
- From Myspace create a short script that uses makeRequest() to fetch a page from your Zend Framework site and echo the result to the screen.
Because of this directive (regardless of the controller you request in the url) the relayproxy controller will be called. You should therefore see the content of the relayproxy controller and therefore the offending HTTP_X_REWRITE_URL.
We have made enquires with MySpace but a quick fix is to stop Zend from looking for this header and therefore redirecting.
To do this:
- You need to change the following section form the Zend class Zend/Controller/request/http.php so that it does not look for the HTTP_X_REWRITE_URL directive.
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // <-- THIS IS WHAT YOU NEED TO REMOVE $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; // <-- THIS IS WHAT YOU NEED TO REMOVE } elseif (isset($_SERVER['REQUEST_URI'])) { $requestUri = $_SERVER['REQUEST_URI']; } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI $requestUri = $_SERVER['ORIG_PATH_INFO']; if (! empty($_SERVER['QUERY_STRING'])) { $requestUri .= '?' . $_SERVER['QUERY_STRING']; } } else { return $this; }
- So you need to change it to something like:
if (isset($_SERVER['REQUEST_URI'])) { $requestUri = $_SERVER['REQUEST_URI']; } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI $requestUri = $_SERVER['ORIG_PATH_INFO']; if (! empty($_SERVER['QUERY_STRING'])) { $requestUri .= '?' . $_SERVER['QUERY_STRING']; } } else { return $this; }
- This section appears around line 326 in the function setRequestUri() in the version 1.0.4
|