• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Zend_Http_Client can't handle %20?

Jaxel

Well-known member
#1
I am trying to use Zend_Http_Client to reach two different URLs...

The first URL works fine:
The problem is with the second URL:
I get kicked out with the following error:
Path "/albums/y268/Eyce/Broken%20Destiny%20Art%20Pack/http://photobucket.com/albums/y268/Eyce/Broken Destiny Art Pack/" is not a valid HTTP path

Is this normal?
 

Jaxel

Well-known member
#2
Let me give a bit more detail...
PHP:
$source = "http://s7.photobucket.com/albums/y268/Eyce/Broken%20Destiny%20Art%20Pack/";

preg_match('#http://[\w\.]*?photobucket\.[a-z]+/albums/(.+?)/*$#i', $source, $matches);

// "y268/Eyce/Broken%20Destiny%20Art%20Pack"
$service_value = $matches[1];

// "http://www.photobucket.com/albums/y268/Eyce/Broken%20Destiny%20Art%20Pack/"
$service_feed = "http://www.photobucket.com/albums/{serviceVAL}/";
$service_feed = str_replace('{serviceVAL}', $service_value, $service_feed);

$client = new Zend_Http_Client($service_feed);
$feed = $client->request()->getBody();
This takes the source URL, matches it against a regular expression and extracts the $service_value and stores it in a variable. Then it takes the $service_value, and places it into the appropriate area of $service_feed. Then it tries to connect to $service_feed using Zend_Http_Client...

The system fails on the last line with the error:
Code:
Path "/albums/y268/Eyce/Broken%20Destiny%20Art%20Pack/http://photobucket.com/albums/y268/Eyce/Broken Destiny Art Pack/" is not a valid HTTP path
 

Shadab

Well-known member
#3
Photobucket, when directing you to the non-www version doesn't return a well-formed URI.
Using the non-www version directly seems to work:

Code:
$service_feed = "http://photobucket.com/albums/{serviceVAL}/";
 

Jaxel

Well-known member
#4
Photobucket, when directing you to the non-www version doesn't return a well-formed URI.
Using the non-www version directly seems to work:

Code:
$service_feed = "http://photobucket.com/albums/{serviceVAL}/";
Thanks... that fixed it... The problem was with photobucket, not my code.