I want to run this script by Ipeenk.com that post to Facebook Groups using Google App Script. But it keeps giving me warn that "Method Utilities.jsonParse is deprecated.Collapse File: Code Line: 25 The method has been marked as deprecated which means that the feature should be avoided and may be removed in the future. Consider using an alternative solution."
Pls how do I fix it.
//------------------------------ Ipeenk ----------------------------------//
var robot={
tokens:[
{nama:"Ipeenk",token:"CAAAACZ****************"}
],
pids:[
"653096888*****",
],
msgs:[
"Hey guys........Hurry up!",
],
pid:""
};
var putaran=0;
function NumpakBecak(almt,prop){
var a=UrlFetchApp.fetch(almt,{
muteHttpExceptions:true,
method:"post",
payload:prop
});
var b=Utilities.jsonParse(a.getContentText());
return b;
}
function koplo(naon){
var a=naon.sort(function(){return 0.5-Math.random()});
a.reverse();
a=a.sort(function(){return 0.5-Math.random()});
return a;
}
function ViaVallen(){
var a=NumpakBecak("https://graph.facebook.com/"+robot.gid+"/feed",{
method:"post",
message:robot.msg,
access_token:robot.token
});
}
function ipeenk(){
robot.token=koplo(robot.tokens)[0].token;
robot.pid=koplo(robot.pids)[putaran];
robot.gid=robot.pid.split("_")[0];
robot.limit=50;
robot.msg=koplo(robot.msgs)[0];
var a=NumpakBecak("https://graph.facebook.com/"+robot.gid+"/feed",{
method:"get",
limit:50,
fields:"id",
access_token:robot.token
});
var b="n";
if(a&&a.data&&a.data.length!=0){
for(x in a.data){if(a.data[x].id==robot.pid){b="y";break}}
}
if(b=="n"){
ViaVallen();
}else if(b=="y"){
putaran++;
if(putaran>=0&&putaran<robot.pids.length){
ipeenk();
}
}
}
It has been replaced by JSON.parse(text), see release note november 2013
simply replace in your code
Utilities.jsonParse(a.getContentText());
with
JSON.parse(a.getContentText());
November 18, 2013
The Apps Script methods Utilities.jsonParse() and Utilities.jsonStringify() have been deprecated in favor of the now-standard JavaScript methods JSON.parse() and JSON.stringify(), which now appear in autocomplete.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With