Why doesn't Twitter feed work on Safari?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

Code: Select all

<a class=\"twitter-timeline\" data-dnt=\"true\" href=\"https://twitter.com/anonymous\"  data-widget-id=\"395906907610697729\" width=\"342\" height=\"500\" >Tweets by @anonymous</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>
This doesn't work on Safari on my iPad.

It begins to do it, by showing a bit of text, but then abandons it all, and stops all code after it running too.

I've since added code to only show when browser is not Safari - but why would it not show?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why doesn't Twitter feed work on Safari?

Post by Celauran »

Works fine for me. Safari 7.0/OSX 10.9
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

On iPad Mini it fails.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why doesn't Twitter feed work on Safari?

Post by Celauran »

Just tested on my iPad. Works there too. That's the only thing I've got on the page, though, so I removed all the backslashes. Check for a missing/extra backslash?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

This is my section right now.
If I strip it out and just use the Twitter code, it fails.

Code: Select all

$ua = $_SERVER["HTTP_USER_AGENT"];
$safari = strpos($ua, 'Safari') ? true : false; // All Safari

    if($safari)
    {
    }
    else
    {
   echo "<td rowspan='2' style='padding-right: 15px'><a class=\"twitter-timeline\" data-dnt=\"true\" href=\"https://twitter.com/anonymous\"  data-widget-id=\"395906907610697729\" width=\"342\" height=\"500\" >Tweets by @anonymous</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script></td>";}
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why doesn't Twitter feed work on Safari?

Post by Celauran »

echo block still works fine on Safari on OS X 10.9 and iOS 7
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

Fine - doesn't for me on my iPad with the latest app software.
it begins to load it, then drops out it, and everything after it. On all other browsers, it works fine.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

Odd - if I echo it inside PHP tags on it's own, within our template, it works. But if it is in a <td> </td> it doesn't in Safari.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why doesn't Twitter feed work on Safari?

Post by Celauran »

I'm out of testing options. Copy/pasted the above into my local MAMP install and onto my Linux server, accessed both via OS X and iOS 7. Can't reproduce anywhere. Sorry.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

Well I just ran it on Safari on my laptop. The Twitter feed "overlays" the next cell. so I set the <td> that the Feed resides to be width='50%' to force it out, but STILL on my ipad is just say "no, not doing any more".
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

It's definitely something to do with Twitter, and using it on an iPad.
If I run it even with the Twitter feed outside of the <?php ?> tags, it loads the whole page, and as it's about to load the feed, it then chucks everything from Twitter onwards down the whole page, out. And I get a white space.

I don't feel it's a Safari issue, as on my laptop Safari it runs nice. It's definitely the iPad at fault, or perhaps a cliche with the browser and the Twitter app ??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why doesn't Twitter feed work on Safari?

Post by Celauran »

I have Twitter app on my iPad as well and I'm not getting the issue. Nothing in your error logs?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why doesn't Twitter feed work on Safari?

Post by simonmlewis »

[Wed Nov 13 15:13:50 2013] [error] [client 59.63.181.81] PHP Notice: Undefined index: HTTP_USER_AGENT in /var/www/vhosts/site.co.uk/httpdocs/index.php on line 587
Only this. But this is only there now to help.
Without this, we either have the feed for those without Safari, or we don't have it at all.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply