الترقية إلى Diamond الخدمة سوف نبني لكم التطبيق الخاص بك الروبوت أو دائرة الرقابة الداخلية
Self, AIML, and scripting

How to call plain text with a json request

قبل marcosnunes نشر Feb 28 2017, 18:38

 

How to make this script call the json webservice and return a plain text?

 

 

function Teaching() {

var text = Http.requestJSON("https://teacherbot.000webhostapp.com/wp-json/wp/v2/pages?slug=" + Http.encode(star[1]);); return JSON.stringify(json[0].content.rendered); } }


}


by admin posted Feb 28 2017, 20:11
I think the code you want is something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Returns WordPress posts.
state TeachEnglish {
  pattern "^ [verbo pronome pronomes] (to) *" answer Teaching();
  function Teaching() {
    var text = Http.requestJSON("https://teacherbot.000webhostapp.com/wp-json/wp/v2/pages?slug=" + Http.encode(star[1]));
    text = json[0].content.rendered;
    text = text.replace("<p>", "");
    text = text.replace("<\/p>", "");
    text = text.replace("\n", "");
    text = text.trim();
    return text;
  }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2178, today: 0, week: 2, month: 15

معرف: 15620372
نشر: Feb 28 2017, 18:38
الردود: 1
الآراء: 2303, اليوم: 1, الأسبوع: 4, الشهر: 18
0 0 0.0/5