Twitter message with html entities get truncated

4 views
Skip to first unread message

mndasher

unread,
Nov 11, 2009, 7:06:49 PM11/11/09
to Twitter Development Talk
I store my content in a MySQL database. The website is using PHP. Data
fields are encoded so that html tags are using entities; i.e. <p> =
&lt;p&gt; When I query the database I decode the entities, and then
strip the tags. That works fine. But some entities don't get
converted. So &nbsp; causes a problem for a cURL message. The message
is truncated at the ampersand. So I did a string replace where &nbsp;
becomes a space. So that solved one problem. But ampersand is still a
problem. Neither &amp; or simply & work. The both result in a
truncated message. A string replace of &amp; with 'and' seems to
work. But is kind of weird.

I have also tried utf8_encode($message) but I don't see any difference
in the output or the result with the API.

All of the API help and samples I have seen use a very simple message
example. I have not seen any help on how to format the actual
message. I saw some where that it should be UTF-8. Mostly the
messages are plain text, but these two characters cause problems. So
do quotes and single quotes as far as that goes. If I add slashes the
slashes come through in the final message.

Is there any real help for these problems?

Randy Brown

unread,
Nov 14, 2009, 5:47:30 PM11/14/09
to Twitter Development Talk
Help from another programming site, use urlencode() . That does the trick.

Brian Morearty

unread,
Nov 15, 2009, 2:06:24 PM11/15/09
to Twitter Development Talk
You wrote "So &nbsp; causes a problem for a cURL message. The message
is truncated at the ampersand."

This could be due to the fact that on UNIX-like systems (including
Mac), the command line interprets the ampersand as "everything before
this point should be run in the background." Anything after the
ampersand is another command.

If this is the problem, here is the solution: put the entire string in
"quotes".

curl "http://...&...&..."

Brian
Reply all
Reply to author
Forward
0 new messages