RcBuilder@walla.com
call centre: 054-5614020

Adwords scripts UTILITIES Using Examples

07
Jun
2014
Posted by: RcBuilder  /   Category: Adwords Scripts / JAVASCRIPT / SEM / UTILITIES   /   No Comments

Adwords scripts UTILITIES Using Examples

// format date
var dt = new Date();
var sDate1 = Utilities.formatDate(dt, ‘GMT’, ‘yy-MM-dd HH:mm:ss’); // 14-02-16 07:02:28
var sDate2 = Utilities.formatDate(dt, ‘GMT’, ‘dd/MM/yyyy’); // 16/02/2014
var sDate3 = Utilities.formatDate(dt, ‘GMT’, ‘HH:mm’); // 07:02

——————–

// encode and decode values
var encoded = Utilities.base64Encode(‘Hello World’);
Logger.log(encoded);

var decoded = Utilities.base64Decode(encoded);
Logger.log(Utilities.newBlob(decoded).getDataAsString());

——————–

// format string
Utilities.formatString(‘%6s’, ‘abc’); // ” abc”

——————–

// convert string to csv
var csvString = “a,b,c\nd,e,f\ng,h,i”;

var data = Utilities.parseCsv(csvString);
for (var i in data)
Logger.log(data[i]); print

var blob = Utilities.newBlob(csvString, ‘text/csv’)
blob.setName(‘Report.csv’);
MailApp.sendEmail(‘rcbuilder@walla.com’, ‘HELLO FROM ADWORDS SCRIPTS’, ‘ATTACHED HTML FILE’, {attachments: [blob]});

——————–

var csvString = “a|b|c\nd|e|f\ng|h|i”;
var data = Utilities.parseCsv(csvString, ‘|’); // print [a, b, c], [d, e, f]

for (var i in data)
Logger.log(data[i][1]); // print ‘b’, ‘e’, ‘h’

——————–

// create blobs from images
var image1 = UrlFetchApp.fetch(‘http://www.myDomain.com/images/image1.jpg’).getBlob();
var image2 = UrlFetchApp.fetch(‘http://www.myDomain.com/images/image2.jpg’).getBlob();

// zip images to file
var zip = Utilities.zip([image1, image2], “myimages.zip”);

// unzip images file
var files = Utilities.unzip(zip);

——————–

// working with json
var str_json = ‘[' +
'{ "Id": 1, "Name": "Roby", "age": 35 },' +
'{ "Id": 2, "Name": "Avi", "age": 33 },' +
'{ "Id": 3, "Name": "Shirly", "age": 36 },' +
'{ "Id": 4, "Name": "Mia", "age": 1 }' +
']‘;

var users = Utilities.jsonParse(str_json);

for(i in users)
Logger.log(users[i].Name);

Author Avatar

About the Author

בניית אתרים ופתרונות טכנולוגים | RcBuilder

No Comments


  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים