Forum Moderators: coopster

Message Too Old, No Replies

Link stops at @.

         

Jim123

11:41 pm on Feb 11, 2011 (gmt 0)

10+ Year Member



When I use these lines to add a tweet to my website the tweet stops as soon as there is an @.

<?php function wp_echoTwitter($username){
include_once(ABSPATH.WPINC.'/feed.php');
$tweet = fetch_feed("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1"); ?>
<a href="http://www.twitter.com/SonyOnline" target="_blank"><?php echo substr($tweet->items[0]['atom_content'], 0, 75).'...'; ?></a>
<?php }
?>


The code works great, but not when there is an @... A tweet like this:
[twitter.com ]

Does anyone has a solution for it?

Thanks!

Jim

coopster

5:22 pm on Feb 23, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The link? Or the text within the anchor tags? Maybe you need to echo the value after using htmlspecialchars() first?

Matthew1980

7:09 pm on Feb 23, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless I misunderstand this issue, which is highly likely ;) couldn't you just convert the chars into their respective ascii entities (I know what I mean but probably got the wrong word there)

There is a well known issue using # in url strings as this can cause it to give unexpected results.

Have a play around with it, and whatever you use to get it to function the way you want, let us know what method you used.

Cheers,
MRb

Jim123

11:27 am on Feb 25, 2011 (gmt 0)

10+ Year Member



Sorry, didn't see the replies before. Yeah, I'm still looking. I haven't had too much time yet to test some things.

The issue might be the same as the # issue. I'll try what coopster suggested, it makes sense. I'll also try to find a working example to see how it is done but that is not easy. I can't image that all tweets are having the same problem. Plenty of them show as they suppose to do...

In the mean time, if someone has the solution to this, please let me know.

Thanks