Any Javascript experts out there?

  • 2
  • Question
  • Updated 8 years ago
Hey All,
I'm adding something into my site called 'Timeline View', it uses Twitter @Anywhere to put the tweets into a div but I need some help.

Here's the code:
<!--

<script src="http://platform.twitter.com/anywhere...." type="text/javascript"></script>
<script src="jquery.js"></script>
<span id="twitter-connect-placeholder"></span>
<script type="text/javascript">
twttr.anywhere(function (T) {
var currentUser,
screenName,
profileImage,
profileImageTag;
if (T.isConnected()) {
currentUser = T.currentUser;
screenName = currentUser.data('screen_name');
profileImage = currentUser.data('profile_image_url');
profileImageTag = "<img src='" + profileImage + "'/>";
$('#twitter-connect-placeholder').append("Logged in as " + profileImageTag + " " + screenName);
};
else {
T("#twitter-connect-placeholder").connectButton();
};
T.User.find(screenName).timeline().first(20).each(function(status) {
$('div#timeline_view').append('<p>' + status.screenName + ': ' + status.text + '</p>');
};
});
</script>
<div id="timeline_view"></div>

‚Äč-->

But nothing is showing up, at all! I don't really know much about Javascript so I was wondering if a more advanced user could cast their critical eyes over it. It might just be a missing semi-colon or something more important I don't know.

Thanks for your help,
Callum
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
  • frustrated

Posted 8 years ago

  • 2
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hello Callum

I'm definitely not a Javascript expert but if you could share with us the link where you got this code from, then perhaps I might be able to figure out what is going on.

Thank you for your patience as we work on this together.
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Hello Callum! I found out what the problem is! You have the second linking code linked to a file that will never be found in your website. Here is the line you have that isn't correctly right: <script src="jquery.js"></script> Do you have it in your resources folder? Do you have jquery.js in your file manager of your site? If you do, then you can just change that part to this:

<script src="resources/jquery.js"></script>

But, if you are not on Yola Silver, then you need to host this file on a hosting site.You can use www.yourjavascript.com That is a free JavaScript file hosting site. All you have to do is upload your JavaScript file and then upload it. Then, they will send the link to your email.

So, the problem was that you linked to a file that wasn't even there! :) lol

I hope this helps! If you have any more questions or if you have a problem with this please let me know.

Happy site building,
Nathan
Photo of SilverX

SilverX

  • 492 Posts
  • 40 Reply Likes
For twitter JSs, they usually do not let the user to host the java script. typical java script they let to put in our site is a short one, and it just call the script, and setup few things.

Above reply is correct. When specifing /jquery.js, it should be mysite.com/jquery.js
can you confirm that you got the script not from their API docs ?
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
<!--
Hi guys, sorry for not replying sooner,
I got the code from Twitter's API documentation, I've also got the jQuery file in my Dropbox and it is linked properly on the site, I still cant understand what's going on, it should be on this page: http://rapitweet.co.uk/timelineviewte... but nothing is appearing.

A portion of the code is from http://platform.twitter.com/js-api.html under the heading 'Facade method examples'

The rest comes from http://dev.twitter.com/anywhere/begin...

I'm not sure what's going on but it should work
:'(

-->
Photo of SilverX

SilverX

  • 492 Posts
  • 40 Reply Likes
Finally, make sure that all java scripts are accessible as anonymous users, and tags are closed well.

Since last 2 months, you must use OAuth layer to connect to twitter.
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
I'm getting it to connect through @Anywhere so it fully authorizes, I've found an error where I missed a bracket. I fixed it and now the connect button is appearing, but nothing else is working.
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
Woah woah woah, hang on! I've got it working! :D Thatnks for your help guys!
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Awesome! I am so glad you got it working!