在AppsScript和Wordpress之间进行通信 [英] Communicate between AppsScript and Wordpress

查看:63
本文介绍了在AppsScript和Wordpress之间进行通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望Google Apps脚本Webapp可以从我的Wordpress中捕获当前的用户名. 我已经为此工作了一段时间,但我无法弄清楚. 我以这种方式尝试过-在wp内运行代码:

I want a Google Apps Script Webapp to catch the current Username from my Wordpress. I've been working on this a while now but I can't figure it out. I tried it this way - inside wp I run the code:

<?php $current_user = wp_get_current_user(); echo '<div id="username" style="visibility: hidden;">' . $current_user->user_login . '</div>'; ?>

现在,我尝试从google web应用程序(在iframe中)捕获ID内容,但无法访问父元素.我如何在两者之间进行交流?

Now I tried to catch the ID content from a google webapp (in an iframe) but I cannot access the parent element. How can I communicate between both?

推荐答案

您可以将值作为参数发送到iframed Webapp.

You can send values to the iframed webapp as parameters.

主页面:

<?php $current_user = wp_get_current_user(); echo '<iframe src="https://script.google.com/macros/s/.../exec?name=' . $current_user->user_login . '"></iframe>'; ?>

应用脚本:

function doGet(e) {  
  var temp = HtmlService.createTemplateFromFile('index');
  temp.name = e.parameters.name;
  return temp.evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

这篇关于在AppsScript和Wordpress之间进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆