GASで作成したウェブアプリケーションへGET通信したいのですが、うまくいきません。
環境:Adobe ExtendScript Toolkit CC
言語:Extend Script
原因が全然わからないので、もしわかる方がいらっしゃいましたら、よろしくお願いします。
参考サイト
http://chocolife.blog80.fc2.com/blog-entry-79.html
GASで作成したウェブアプリケーション
実際のコード
javascript
1var reply = ""; 2var conn = new Socket; 3if (conn.open ("script.google.com:80")) { 4conn.write ('GET' + ' /macros/s/AKfycbzrGvQGGzyKS2tidre9gHrwNFBub3zItraE7DFynniHvYhw_FBL/exec' + 'HTTP/1.0\r\n' 5 + 'Host: ' + 'script.google.com' + '\r\n' 6 + 'User-Agent: ' + 'InDesign/6.0' + '(Macintosh; U; Intel Mac OS X 10_5_6; ja-jp)' + '\r\n' 7 + 'Authorization: Basic username:password' + '\r\n' 8 + '\r\n'); 9reply = conn.read(999999); 10$.writeln(reply); 11conn.close(); 12}
返ってくるreplyの内容
HTTP/1.0 404 Not Found Content-Type: text/html; charset=UTF-8 Referrer-Policy: no-referrer Content-Length: 1639 Date: Sun, 11 Aug 2019 15:31:12 GMT <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 404 (Not Found)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style> <a href=//www.google.com/><span id=logo aria-label=Google></span></a> <p><b>404.</b> <ins>That���s an error.</ins> <p>The requested URL <code>/macros/s/AKfycbzrGvQGGzyKS2tidre9gHrwNFBub3zItraE7DFynniHvYhw_FBL/execHTTP/1.0</code> was not found on this server. <ins>That���s all we know.</ins> 結果 : true
ちなみにhttps://www.yahoo.co.jp/で試した場合
var reply = ""; var conn = new Socket; if (conn.open ("www.yahoo.co.jp:80")) { conn.write ('GET' + '/' + 'HTTP/1.0\r\n' + 'Host: ' + 'www.yahoo.co.jp' + '\r\n' + 'User-Agent: ' + 'InDesign/6.0' + '(Macintosh; U; Intel Mac OS X 10_5_6; ja-jp)' + '\r\n' + 'Authorization: Basic username:password' + '\r\n' + '\r\n'); reply = conn.read(999999); $.writeln(reply); conn.close(); }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd"> <html lang="ja"> <head> 省略 </head> <body class="yj950-1"> 省略 </body> </html> 結果 : true

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/12 02:41
2019/08/12 03:00
2019/08/12 03:04 編集
2019/08/12 03:07
2019/08/12 03:12
2019/08/12 03:12
2019/08/12 03:16