Twitter connect button help

  • 1
  • Question
  • Updated 8 years ago
  • Answered
Hello everyone,

I'm a bit confused about some code on my website, there is a Twitter connect button. When this is clicked and the user signs in, it should change to their profile picture, username and a signout button. But it doesn't appear. The only time it appears is if you refresh the page. This is the same when you click the signout button, it should clear and show a connect button, but again, you have to refresh.

Does anyone know how I can stop this, I don't want to make the whole page refresh just to change the login options. Will I be able to use AJAX or JS or something?

Thanks

Callum
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
  • at http://rapitweet.co.uk

Posted 8 years ago

  • 1
Photo of Laura Thomas

Laura Thomas, Social Media Coordinator

  • 4536 Posts
  • 211 Reply Likes
Hi Callum,

Sorry to hear some of your code is not rendering the way you would like it to. I am happy to refer your inquiry to our HTML team and they will be glad to help. Please allow them 48 hours to review your code and respond to your inquiry.
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
Thanks Laura! :)
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hello Callum

I'm not sure if I have the majik to make this work or not. Can you please share with me your Twitter connect code?

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

Callum

  • 357 Posts
  • 32 Reply Likes
Hi Sanja,

Here's the code:
<!--

<div align="center">
<span id="twitter-connect-placeholder"></span>
</div>
<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(profileImageTag + "<br />" + "Hello there, You're logged in as @" + screenName + "<br><button id=\"signout\" type=\"button\">Sign out of Twitter</button></div>");
$("#signout").bind("click", function () {twttr.anywhere.signOut()});
T.hovercards();
} else {
T("#twitter-connect-placeholder").connectButton({ size: "xlarge" });
};

});

</script>

-->

It only changes when I refresh the page :(
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
Hey, I was just wondering if there's any news about this yet?

Thanks,
Callum
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hello Callum

I'm looking into this now. I don't know if I'll be able to resolve it but I'll try my best.
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hi Callum

I'm wondering if there is a part missing from your code? Please take a look at this link which gives an in-depth tutorial on how to add Twitter Connect to your site: http://dev.twitter.com/anywhere/begin
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
Hi Sanja,

I've looked through the documentation and I haven't missed anything out. What I did think though was, what if I added all that code to a JS function and run that on page load and when the auth is completed? Would that work?
Photo of Brianna

Brianna

  • 2045 Posts
  • 92 Reply Likes
Hey Callum,
I have referred your request to Sanja. She is currently offline, but will answer as soon as she comes back. We appreciate your patience!
Cheers!
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
Ok, thanks Brianna!
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
I must confess Callum.. my knowledge of how this works is quite limited. You can always try but I don't know if that would work. Perhaps you may be able to contact them to see if they have run into this before and they may have some suggestions?
Photo of Callum

Callum

  • 357 Posts
  • 32 Reply Likes
Ok, thanks Sanja, I'll email Twitter with this. Thanks again!