0

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'

Raj
  • 22,346
  • 14
  • 99
  • 142

3 Answers3

3

| 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

Joe
  • 46,419
  • 33
  • 155
  • 245
  • This feed is for a search result. Users might search for something with a space character. What is the best character to replace space character with? – Raj Nov 15 '11 at 10:28
  • Space should be `+`. Updating my answer with more info. – Joe Nov 15 '11 at 10:28
2

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"
Māris Kiseļovs
  • 16,957
  • 5
  • 41
  • 48
2

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.

Community
  • 1
  • 1
Janis Veinbergs
  • 6,907
  • 5
  • 48
  • 78