How to fix Parser Error
How can I fix this error?
I have downloaded PHP jsConnect client library, and I have a test URL that is only a link that redirects to (http://myforum.com/?p=/sso/index.php)
This is my code of index.php ,
<?php
header('Content-Type: application/javascript');
$message = "This alert tests if connection is successful";
echo "alert('$message');";
require_once('/functions.jsconnect.php');
//require_once dirname(FILE).'/functions.jsconnect.php';
// 1. Get your client ID and secret here. These must match those in your jsConnect settings.
$clientID = "1122334455";
$secret = "abcdefghi";
// 2. Grab the current user from your session management system or database here.
$signedIn = true; // this is just a placeholder
// YOUR CODE HERE.
// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();
if ($signedIn) {
// CHANGE THESE FOUR LINES.
$user['uniqueid'] = '44556677';
$user['name'] = 'John MARTIN';
$user['email'] = 'john.martin@gmail.com';
$user['photourl'] = '';
}
// 4. Generate the jsConnect string.
// This should be true unless you are testing.
// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.
$secure = true;
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
PHP Version: 5.3**
**Vanilla Version: 2.2****
I need to log on with the user "John Martin", but when I press the link redirects me to my forum I got Parser Error
Comments
Anyone please?
What does the url look like that gives you the parse error?
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Like this, @hgtonight http://myforum.com/index.php?p=/entry/jsconnect/error
Actually, I placed an alert as you see on my code to test if my index.php runs but does not, so I think that my problem is on that file
I did what you suggest placing $secure = false instead of $secure = true but the Parser Error is still active
@hgtonight
And this is how I configured Jsconnect on my forum
why are you not using pretty urls?
Please try to fix this by fixing your htaccess file and also check you have Rewrite Url enabled in the config.php
Not using pretty Urls is the cause of many many many issues. Plus it looks ugly ..
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
@vrijvlinder
I did what do you suggest me to enable "Rewrite URL" in the config.php $Configuration['Garden']['RewriteUrls'] = TRUE;
But when I try to access Discussions my forum breaks out....
It gives me the following: ## ¡Object not found! Error 404 and the url shows this: http://myforum.com/discussions
That may be because the htaccess file rewrite module needs to also be enabled. Please post the contents of the htaccess
file .
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Pretty urls is something you should fix, but not the cause of this issue. Go to your sso endpoint on your server (whatever url will load your custom index.php file). It isn't outputting json, which is causing your parse error. Test it out.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight
Ok, I got it.. the reason is that json is not outputting, but what do you mean about going to my sso endpoint? I think that you are talking about index.php, which main code I post it at the beginning of this discussion and I really don't know what I need to modify
You need to get to the output of the index.php file. This should be somewhere outside of the forum software.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight
I google for my problem as "JSON not responding" and one user said that he deactivated some plug ins and for some reason json worked, this is the discussion https://vanillaforums.org/discussion/23766/json-sso-not-working
And gets a kind of sense cause the vanilla debug shows me this messages:
Undefined property: DiscussionsController::$Offset in /www/htdocs/plugins/MFCDiscussionPagination/class.MFCDiscussionPagination.plugin.php line 41
Undefined variable: Limit in /www/htdocs/plugins/MFCDiscussionPagination/class.MFCDiscussionPagination.plugin.php line 30
You can try disabling the MFCDiscussionPagination plugin, but I don't think that is the issue.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight
Ok I think that I'm starting to find the light at the end of the tunnel, and this might be hard to explain..
I have /www that contains htdocs , old , and vanilla as you see here
/htdocs , besides other folders, contains test.php (This file have a simple url that redirects to http://myforum.com/?p=/sso/index.php)
Then, on /vanilla it's all my forum and also there is /sso folder that contains PHP jsConnect client library files as I show you here
I don't know if this is what you mean about getting output of the index.php file ?
Still online waiting for your help, THANKS!
You should be able to see the output of your index.php at http://forums.example.com/vanilla/sso/index.php.
I would suggest you move the entire sso folder out of the vanilla folder and into a separate area. It is generally put somewhere convenient for the connecting software.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight
Please tell me that this is a good notice...
I move my /sso folder outside /vanilla and I place it on /htdocs
And when I'm on test.php and try to access to index.php it gives me this
I think that it is a good notice, because Parser Error disappeared, but I have a new one, nothing of my index.php runs, only the alert that I put but it only shows as text not as an alert as I want
Still online
EDIT:
I don't know if this helps , it is the /htdocs
Change your require once line to not be an absolute path:
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight
I really think that I have good news, I modified my code of index.php as you said in your last reply like this:
<?php
header('Content-Type: application/javascript');
require('functions.jsconnect.php'); <--- I ONLY MODIFIED THIS LINE
...
...
Same code
And when I go to test.php and press my URL that redirects to my forum I get this:
Looking at functions.jsconnect.php I found this
So my conclutions are:
1) Having all in /www/htdocs was right
2) I think that I am very close to find my problem because functions.jsconnect.php executes a little, but it does
3) Again, Parser Error disappeared
Thanks thanks thanks for your help hgtonight, If we are very close to the solution I will be grateful forever
@hgtonight
Modified this line
$secure = true;
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
to this:
$secure = false;
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
And then I got this
¿I'm more close to the solution?
You have verified that your sso endpoint is executing and spitting out JSON via the jsconnect php library.
You still need to modify that file to load the user information from your other connecting software. Once that is done and working, set secure back to true and you should be good to go.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight
I think you mean index.php to find where it can load the user info
I'm gonna try and I will inform you when everything executes correctly, Thanks for your help