could anyone tell me what’s wrong with this code and how to fix it? Any help would be appreciated, thanks. The error is: “null – parsing error: Identifier direcly after number”.
JavaScript
x
12
12
1
/**
2
* Authorize Google Youtube API.
3
*/
4
var auth = function(immediate, callback) {
5
gapi.client.setApiKey(AIzaSyB7xh-QBr-4kpV7RMlYMZ_aUQB5FmfMRLs);
6
gapi.auth.authorize({
7
client_id: 1077089514511-s11blgkep9up7cu7hnq0c84t12ba8ihe.apps.googleusercontent.com,
8
scope: https://www.googleapis.com/auth/youtube,
9
immediate: immediate
10
}, callback);
11
};
12
Here’s the other code with the error “ChannelId already defined”:
JavaScript
1
14
14
1
var getChannelURI = function() {
2
var re = /youtube.com/(user|channel|c)/([^/]+)/,
3
m;
4
var channelId = "$"('meta[itemprop=channelId]').attr('content');
5
debug(channelId);
6
if (channelId) {
7
return channelId;
8
}
9
var channelId = "$"('meta[property="og:url"]').attr('content');
10
if (channelId) {
11
return channelId.match(re)[2];
12
}
13
};
14
Advertisement
Answer
In JavaScript objects, string values must be wrapped with quotation marks, you can use "string"
or 'string'
.
This is what your code should look like.
JavaScript
1
17
17
1
/**
2
* Authorize Google Youtube API.
3
*/
4
var auth = function (immediate, callback) {
5
gapi.client.setApiKey("AIzaSyB7xh-QBr-4kpV7RMlYMZ_aUQB5FmfMRLs");
6
gapi.auth.authorize(
7
{
8
client_id:
9
"1077089514511-s11blgkep9up7cu7hnq0c84t12ba8ihe.apps.googleusercontent.com",
10
scope: "https://www.googleapis.com/auth/youtube",
11
immediate: immediate,
12
},
13
callback
14
);
15
};
16
17