I hope this is possible. I have a HTML file that loads an js file using: <script src="js.js"></script>
In this script there is a var: var score = 0; This var changes when people get points.
Now in this same HTML file I have added the following Dialog script (also see https://developers.facebook.com/docs/reference/dialogs/feed/ for more info):
FB.init({appId: "xxxxxxxxxxxxx", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: '',
name: 'I just got a new high score of [xx] points!',
caption: 'Think you can do better?',
description: 'Join me.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
This script works and the Dialog box appears. Now at the part [xx] points I want to show the points people have earned.
I’ve tried the following:
Pushed the var result to an input field <input type="text" id="score" name="score" value="0" readonly /> using $('#score').val(document.getElementById('sc').innerHTML); in the js.js file, which results that the score shows up in the input field.
And then tried at the [xx] part: ' + document.getElementById('score').innerHTML + ', but this didn’t work. Perhaps this approach is wrong and there is a better way, but how can I show the score in the Dialog?
Kind regards,
Maurice
As far as I can tell from your description
scoreis a global variable. you can do something like: