Login Button script firstName and lastName is blocking my website

29 posts / 0 new
Last post
Mon, 01/02/2012 - 15:53
Login Button script firstName and lastName is blocking my website

Hi! I am using Wordpress.Org platform for my website.

I do all by JSAPI Tutorial... get API key...etc.

It is working for me ok if i use Basic Login Button:

<script type="in/Login"></script>

Also, it is ok if i use this:

<script type="in/Login">
You've logged in!
</script>

But it doesnt work when i use this:

<script type="in/Login">
Hello, <?js= firstName ?> <?js= lastName ?>.
</script>

It is blocking my website... It doesnt load my homepage at all. Please, why this is happening? Help?!?!?

Forward thanks,

W

Jeremy Johnstone's picture
Developer Advocate
Joined: 04/17/2011
Tue, 01/03/2012 - 13:21

Do you have PHP short open tags enabled?

-Jeremy

Tue, 01/17/2012 - 15:12

Yes. I have check out PHP.ini via CPanel Editor. Its On.

short_open_tag=On

victor lenin muñoz isler's picture
Joined: 01/19/2012
Thu, 01/19/2012 - 10:37

i have the same problem, it doesnt work when i use this:

<script type="in/Login">
Hello, <?js= firstName ?> <?js= lastName ?>.
</script>

tell me syntax error, unexpected '=

Eugene O&#039;Neill's picture
Developer Advocate
Joined: 01/07/2011
Sun, 01/22/2012 - 13:59

You have to disable short tags in PHP or change the template method used. If you have short tags enabled in PHP, it will try to execute, e.g. it thinks it's seeing this:

1
2
3
<?php
js= firstname
?>

If you can't disable short tags, you can try doing this:
1. in your in.js loader, add custom templateMarkers

1
2
3
4
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
  apiKey: ....
  templateMarkers: <% %>
</script>

2. Change the template inside of your Login tag:

1
2
3
<script type="IN/Login">
Hello, <%= firstName %> <%= lastName %>.
</script>

You can use anything you want for your template markers, just make sure you have opening and closing tags separated by a space:

1
2
3
templateMarkers: <% %>
templateMarkers: {{ }}
templateMarkers: ${ }

Also make sure you choose something that doesn't conflict with anything else you're using.

Hope it helps.

- Eugene

victor lenin muñoz isler's picture
Joined: 01/19/2012
Sun, 01/22/2012 - 15:13

Thanks Eugene. but I think I will not use linkedin auth because I can not capture the user's email.
thanks anyway

Sun, 01/29/2012 - 07:26

I changed in header ..in <head>...

<script type="text/javascript" src="http://platform.linkedin.com/in.js">
apiKey: ...my apikey...
templateMarkers: <%= %>
</script>

...in the body...

<script type="IN/Login">
Hello, <%= firstName %> <%= lastName %>.
</script>

My homepage is not blocked now, but there is no Sign in Linkedin button or Hello, name...etc... Doesnt work.

Nothing! Any suggestion?!

Fwd tnx!!!

Sun, 01/29/2012 - 07:33

Also, i dont know how to disable short open tags. I am using CPanel.

Eugene O&#039;Neill's picture
Developer Advocate
Joined: 01/07/2011
Sun, 01/29/2012 - 22:36

Can you provide a link to your website? If the button doesn't show up at all, it's probably the API key isn't configured properly. Make sure you've specified your domain for the API key (also note that www.example.com is different from example.comc for security reasons).

Wed, 02/01/2012 - 08:12

It is working for me ok if i use Basic Login Button:

<script type="in/Login"></script>

So, i dont believe that API key is wrong. I can give you username and password, server login...etc....to take a look at it...if is ok with you. ...?!?!?!

Or maybe you can give me instruction how to disable short open tag. Thanks in advance!

Jeremy Johnstone's picture
Developer Advocate
Joined: 04/17/2011
Wed, 02/01/2012 - 19:05

Hi,

We just need the URL to your website so we can see the issue directly.

Thanks!

-Jeremy

Kirsten Jones's picture
Joined: 06/30/2011
Mon, 02/06/2012 - 11:59

You're loading the javascript framework several times in the page. Try loading it just once, in the first spot, with the key - and then don't load it again for the other login/share buttons.

Chan Naseeb's picture
Joined: 01/09/2012
Tue, 02/14/2012 - 02:41

Even I am loading it once, but I don't see anywhere any login button?
What is the problem?
My API key is correct

Jeremy Johnstone's picture
Developer Advocate
Joined: 04/17/2011
Tue, 02/14/2012 - 12:00

Hi Chan,

Can you please provide a link to the page? Happy to investigate.

Thanks!

-Jeremy

Chan Naseeb's picture
Joined: 01/09/2012
Tue, 02/14/2012 - 12:43

Hi Jeremy
Yes, for sure! Here we go..
https://www.linkedin.com/secure/developer app name is Paige
But currently I set it to localhost so that to check it works or not but it didn't show any thing.

and the real url is www.paige.ask-cs.com

for which I want linkedin to function...

Let me know if you have any further question?
Thanks!

Jeremy Johnstone's picture
Developer Advocate
Joined: 04/17/2011
Tue, 02/14/2012 - 13:55

Hi Chan,

Unfortunately I can't see anything at that URL other than a Google hosting error page. Since you're viewing it as localhost, can you paste the markup of your page here: http://gist.github.com and then provide a link to it?

Thanks!

-Jeremy

Chan Naseeb's picture
Joined: 01/09/2012
Wed, 02/15/2012 - 00:05

https://gist.github.com/ef16bf4fd6ceb4c16836

Here we go

Chan Naseeb's picture
Joined: 01/09/2012
Wed, 02/15/2012 - 00:12

or you can try paige.ask-cs.com (without www)

Edward Peciulis's picture
Joined: 07/14/2011
Wed, 02/15/2012 - 07:49

I am having the same issue.

The login button doesn't show and neither does the Member Data function (I'm exactly copying the code snippet from the JavaScript API Developer Console: http://bit.ly/f4kqHL and I can see the profiles on the linked example page, but not on my page).

When I set short_open_tag = Off in my php.ini file (be sure to restart the server when you do this), the button shows up. However, the Member Data function is still broken. I guess I'll log that issue separately since it's not exactly on topic.

Cheers,

Ed

Yoav Yaari's picture
Joined: 02/04/2012
Fri, 02/17/2012 - 23:31

Same here: http://bit.ly/xOG5EL

I'm using a PHP server (with short_open_tag=Off and the code is the second step of the tutorial. I don't see the button at all.

I have a feeling that the API key I get is just too short. In some sample code I see codes which look like: up8hQML83EYXioHsDsw4ktySh3AoNwJzhY8WDmJPZWdqR5zaIvw9r0phLieHH_c5 (I changed a few characters here) where I get something like 0xvnygzuhy6g - could this be the reason?

Edward Peciulis's picture
Joined: 07/14/2011
Sat, 02/18/2012 - 09:17

I've also noticed that the API keys shown in the examples are all significantly longer than the API key I get. However, I've been able to use the REST API successfully and get the login with LinkedIn button to show using the JS API, so I don't think the short API key is the problem.

It's a discrepancy that confuses people and the examples should be updated accordingly.

In addition, it's really odd that one would have to dig into the discussion forums to find out that you should check the short_open_tag setting in your php.ini file. This should be highlighted in large font, bolded text on the Getting Started with the JavaScript API tutorial. Something like: "If you are getting errors when you use the js tags, you should disable short open tags [include here a detailed step-by-step guide on how to do this]".

Cheers,

Ed

Eugene O&#039;Neill's picture
Developer Advocate
Joined: 01/07/2011
Sat, 02/18/2012 - 18:42

@Yoav, when you define your templateMarkers, make sure you define them without an equal sign =. e.g.

1
templateMarkers: <% %>

keep the equal for the output though:

1
Hello, <%= firstName %> <%= lastName %>.

@Edward, thanks for the feedback, we will definitely update the documentation with this in mind. We strive to provide both the tools and the reference material needed for developers. Occasionally we don't get it perfect the first time, but we try our best.

Yoav Yaari's picture
Joined: 02/04/2012
Sat, 02/18/2012 - 20:01

Thanks. Now it works.

Chan Naseeb's picture
Joined: 01/09/2012
Mon, 02/20/2012 - 00:19

HI Jeremy
For me it still does not show?
And @others, I am using Javascript not PHP, so let me know any ideas?
Thanks

Eugene O&#039;Neill's picture
Developer Advocate
Joined: 01/07/2011
Mon, 02/20/2012 - 00:39

@Chan, if you're not using PHP, the info in this thread doesn't really apply to you. It sounds more like you're API key isn't configured with your domain properly.

Chan Naseeb's picture
Joined: 01/09/2012
Mon, 02/20/2012 - 01:46

@Eugene
I don't think so, it is configured properly...I guess...
well the weird thing is it should work with localhost...but it doesn't?

Sananaj Nayak's picture
Joined: 03/20/2012
Wed, 03/21/2012 - 03:13

Even I am using localhost and when i try to run it its says JavaScript API Domain is restricted to localhost how do we invoke our htm pages in browsers

Kirsten Jones's picture
Joined: 06/30/2011
Wed, 03/21/2012 - 08:29

What do you have in your Javascript API Domain field, and what does the browser URL window show (exactly)?

Sananaj Nayak's picture
Joined: 03/20/2012
Wed, 03/21/2012 - 21:57

I have specified Javascript API domain as http://localhost . and while loading in the browser i am doing it as http://localhost/myhtml.html