Page 1 of 1
Simple coding question for any programmer
Posted: Wed Jun 23, 2010 3:11 pm
by mark-in-dallas
I have created, well actually I had a ton of help in creating a plugin script for myBB to tweet new threads to Twitter.
It works now, but I want to add line breaks between the dateline, subject, username and url. Everything I've tried has generated an error. Can anyone show me how to accomplish this?
Code: Select all
$tw->updateStatus("[".my_date('M d',$thread_info['dateline'])."] " . $new_thread['subject'] . " " . $new_thread['username'] . " " . $url);
Re: Simple coding question for any programmer
Posted: Wed Jun 23, 2010 3:14 pm
by John Cartwright
Code: Select all
$tw->updateStatus("[".my_date('M d',$thread_info['dateline'])."]\r\n" . $new_thread['subject'] . "\r\n" . $new_thread['username'] . "\r\n" . $url);
Or use the PHP constant PHP_EOL
Re: Simple coding question for any programmer
Posted: Wed Jun 23, 2010 3:22 pm
by mark-in-dallas
Well that didn't error out on me, but it didn't place trhe line breqaks either. I'm dumbfounded. Any other suggestion?
Here's what I the tweet looks like:
PheroTruth [Jun 23] Twitter tweet test mark-in-dallas
http://pherotruth.com/Thread-Twitter-tweet-test
Re: Simple coding question for any programmer
Posted: Wed Jun 23, 2010 3:26 pm
by John Cartwright
Oops, I thought you meant new lines (\r\n), not line breaks (<br>). New lines won't reflect a "new line" in HTML, as per line breaks.
Code: Select all
$tw->updateStatus("[".my_date('M d',$thread_info['dateline'])."]<br />" . $new_thread['subject'] . "<br />" . $new_thread['username'] . "<br />" . $url);
Re: Simple coding question for any programmer
Posted: Wed Jun 23, 2010 3:32 pm
by mark-in-dallas
I tried that first and it tweeted the break tags
New lines would be fine, but Twitter doesn't seem to recognize the \r\n\, break tags or any other code
Re: Simple coding question for any programmer
Posted: Wed Jun 23, 2010 4:14 pm
by ell0bo
I don't use twitter, so pardon my ignorance, but does twitter even let you tweet multiple lines? Odds are they are sanitizing anything coming in, which translates your < to < so <br> won't work. If they don't recognize \r or \n then you are out of luck as far as I know...
Re: Simple coding question for any programmer
Posted: Wed Jun 23, 2010 4:41 pm
by mark-in-dallas
ell0bo wrote:I don't use twitter, so pardon my ignorance, but does twitter even let you tweet multiple lines? Odds are they are sanitizing anything coming in, which translates your < to < so <br> won't work. If they don't recognize \r or \n then you are out of luck as far as I know...
I think you may be right, but it did post the break tags as tags, so it didn't sanitize that anyway.
I did try to tweet from my page though, and you're are right, it stripped out my line breaks.
So, it looks like html code is not allowed and I'm sure PHP code is not, and it's either ignored or posted as text.
Guess I'm SOL on adding the line breaks.
I thank you guys for your assistance though!