Simple coding question for any programmer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mark-in-dallas
Forum Newbie
Posts: 4
Joined: Wed Jun 23, 2010 2:55 pm

Simple coding question for any programmer

Post 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);
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Simple coding question for any programmer

Post 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
mark-in-dallas
Forum Newbie
Posts: 4
Joined: Wed Jun 23, 2010 2:55 pm

Re: Simple coding question for any programmer

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Simple coding question for any programmer

Post 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);
mark-in-dallas
Forum Newbie
Posts: 4
Joined: Wed Jun 23, 2010 2:55 pm

Re: Simple coding question for any programmer

Post 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
ell0bo
Forum Commoner
Posts: 79
Joined: Wed Aug 13, 2008 4:15 pm

Re: Simple coding question for any programmer

Post 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...
mark-in-dallas
Forum Newbie
Posts: 4
Joined: Wed Jun 23, 2010 2:55 pm

Re: Simple coding question for any programmer

Post 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!
Post Reply