API - Permission denied.

Subscribe to API - Permission denied. 5 posts

avatar for AllusiveGold AllusiveGold 11 posts
Flag Post

I am using the kongregate_shell.html

Below is said shell:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”&gt;
<html>
<head>
<title>Dragon Knight</title>
<!-- Load the Kongregate Javascript API --> <body> API is finished loading function onLoadCompleted(){ // Get a global reference to the kongregate API. This way, pages included in the // iframe can access it by using “parent.kongregate” parent.kongregate = kongregateAPI.getAPI();

var kongregate = parent.kongregate();
// Embed the game into the “contentdiv” div, which is defined below. You can also // manually create your own iframe, this function is just for convenience. // This example also passes along the kongregate user_id and game_auth_token so // that the page can use them for authentication. var params = “kongregate_user_id=” + kongregate.services.getUserId() + “&kongregate_game_auth_token=” + kongregate.services.getGameAuthToken() + “&random=” + (Math.random() * 1000000000) + “&level= <?php echo $userrow[‘level’] ?>”; kongregateAPI.embedFrame(“index.php” + params); } // Begin the process of loading the Kongregate API: kongregateAPI.loadAPI(onLoadCompleted); var level = level; if(level != NaN){ kongregate.stats.submit(Level,level); } } <div> <!-- You can manually put your game iframe in here instead of calling embedFrame above if you wish --> </div> </body> </html>

As you can see this has been modified slightly, and I can report that the server actually does receive my current level in my game which is 9.

However, when loading my game I receive this error when " kongregate.stats.submit(Level,level); " Is not " parent.kongregate.stats.submit(Level,level); "

[04:49:03.790] ReferenceError: kongregate is not defined @ http://www.gatheringofmagic.com/index.php:47

This is stating to me that kongregate doesn’t exist?

When i try “@parent.kongregate.stats.submit(Level,level);@” I receive this error:

[04:50:31.083] Error: Permission denied to access property ‘kongregate’ @ http://www.gatheringofmagic.com/?(this part is hidden).

As you can see It states I have no permissions to access this ‘kongregate’

I have emailed tech, asked a few developers and even offered money to random people outside of Kong for help, and, nothing.

I found the PHP/JS work-around via another dev, but it’s not letting me access It.

I call this function from a function called donothing(); with php, which means when you login and go to a town, you submit stats.

My game is like 98% PHP/SQL.. hosted via IFRAME, It even states I can access API within an IFRAME using parent.kongregate

So.. Am i lost or what? Because as far as I can see the data is pretty much correct?

 
avatar for player_03 player_03 1249 posts
Flag Post
Originally posted by AllusiveGold:
var kongregate = parent.kongregate();

Are you sure it’s a function?
If so, that would probably explain why “parent.kongregate.stats.submit(Level,level);” is failing.
If not, that might explain why you’re getting a “not defined” error.

 
avatar for AllusiveGold AllusiveGold 11 posts
Flag Post

To be honest I code PHP, not really javascript, this Is new to me, I dont know if it Is being used as a function or not, I do know:

kongregate Reads my level as 9 when submitting, it errors out with the above issue.

 
avatar for AllusiveGold AllusiveGold 11 posts
Flag Post

really? Out of all the users.. no one Is even able to help? Cool story.

 
avatar for Senekis93 Senekis93 4090 posts
Flag Post

parent.kongregate = kongregateAPI.getAPI();
What’s the point of that line? I’ll just comment it out.

Ah, that didn’t work…
Let’s just reference it (yes, the commented out thing) as a function and see what happens:
var kongregate = parent.kongregate();

OMG, why on earth does it say it’s not defined? I’ll just make a thread and wait for someone else to solve it.

12 days later…

Ok, let’s check if someone already posted some code which I can copy and paste…

A few seconds later…

Originally posted by AllusiveGold:

really? Out of all the users.. no one Is even able to help? Cool story.