cURL linebreaks problem when posting to a form (PHP)

Scito

New member
Jan 2, 2007
150
3
0
The Netherlands
Hi guys,

I'm working on a system to automatically create and submit rss feeds. However, I stumbled onto a problem I can't seem to solve: passing linebreaks to a textarea with cURL.

The website I'm trying to submit to is l*i*n*k*s2rss.com (don't want to get this indexed). It's all working fine, except my list of "URL's" aren't being passed properly. Instead of getting a nice feed with my different links, I get this:
Code:
http://www.links2rss.com/feed/853406074.xml

My PHP code is looking like this currently:
Code:
    $notindexed[] = 'http://www.wikipedia.org';
    $notindexed[] = 'http://www.cnn.com';
    $notindexed[] = 'http://www.apple.com';
    $notindexed[] = 'http://www.squidoo.com';
    $notindexed[] = 'http://www.squidoo.com';
    $notindexed[] = 'http://www.kpn.com';

    shuffle($notindexed);

    $links = '';

    foreach($notindexed as $url) {

        $links .= $url;

    }

    $URL = 'http://links2rss.com/convert.php';
    $linktitle = '{my|the|our} {awesome|great|uber|nice|good looking|favourit} {cooking|gaming|sports|news|working} {article|speech|blogpost|letter} {online|on the internet|ever}';
    $linkdesc = '{read now|great article|good news}';

    $feedtitle = 'feed online '. rand(1,9999);

    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL,$URL);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "feedtitle=". $feedtitle ."&linkslist=". $links ."&maxlinks=30&feedlink=http://www.mywebsite.com&linktitle=". $linktitle ."&linkdesc=". $linkdesc);
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_REFERER, 'http://links2rss.com');
    $Content = curl_exec ($ch);
    curl_close($ch);
    
    $Content = preg_replace("/feed\/([0-9]+)\.xml/si","http://www.links2rss.com/feed/$1.xml",$Content);

    echo $Content;

Any thoughts how to solve this? I tried adding \n and \r but it doesn't seem to help..
 


urlencode() didn't have anything to do with this, what did however was using double quotes ("). When I tried adding \n behind every URL, I did it like this:

Code:
$links .= $url .'\n';

While it should be this:

Code:
$links .= $url ."\n";
 
urlencode() didn't have anything to do with this, what did however was using double quotes ("). When I tried adding \n behind every URL, I did it like this:

Code:
$links .= $url .'\n';
While it should be this:

Code:
$links .= $url ."\n";


Well durr, but your code doesn't show that usage now does it.

And it still needs to be url encoded.