Raj
Raj

Reputation: 22926

Zend says this URI is not valid

I am generating a feed using Zend Framework.

When I am setting a link like the one below, I get an error

$feed = new Zend_Feed_Writer_Feed;
$url = "http://www.example.com/search?s=chris|gayle|pics&device=1"
$feed->setLink($url);

I searched through Zend_Uri.php and Http.php, I was not able to figure out the problem.

exception 'Zend_Feed_Exception' with message 'Invalid parameter: parameter must be a non-empty string and valid URI/IRI'

Upvotes: 0

Views: 2905

Answers (3)

Janis Veinbergs
Janis Veinbergs

Reputation: 6988

According to Which characters make a URL invalid? | is not a valid symbol.

To have those characters in url, you must encode your url. You could use urlencode method to do this.

Upvotes: 2

Māris Kiseļovs
Māris Kiseļovs

Reputation: 17275

You may need to urlencode values in your URI

Correct URI will be "http://www.example.com/search?s=chris%7Cgayle%7Cpics&device=1"

Just use urlencode() or rawurlencode(); to encode URI parts.

$url = "http://www.example.com/search?s=".urlencode("chris|gayle|pics")."&device=1"

Upvotes: 2

Joe
Joe

Reputation: 47609

| is not allowed. Use %7C instead.

For more info, see http://en.wikipedia.org/wiki/Percent-encoding#Types_of_URI_characters

To encode a url use urlencode. This will make sure all characters are correctly encoded into a standard URI.

http://php.net/manual/en/function.urlencode.php

Upvotes: 3

Related Questions