我使用报告API(版本4)和PHP客户端库成功地从Google Analytics下载结果.但我还没弄清楚如何正确过滤这些结果.
我看到这将如何通过cURL,但不通过客户端库.我查看了客户端库代码,并且有一个类方法:
apiclient-services/Google/Service/AnalyticsReporting/ReportRequest.php:
public function setMetricFilterClauses($metricFilterClauses)
Run Code Online (Sandbox Code Playgroud)
我没有看到任何文档或关联的get方法的任何用法:
public function getMetricFilterClauses()
Run Code Online (Sandbox Code Playgroud)
是否有通过PHP客户端库使用过滤器的示例?
我需要使用 SSL 和管理缓存在 AWS S3 上部署 React 应用程序。需要哪些步骤,我可能会遇到哪些问题?
从PHP5.6升级到PHP7后,我遇到了以下错误:
sapi_apache2.c(326): PHP Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/var/lib/php/7.0/session)
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我们使用了自定义的会话处理程序,该处理程序将写入数据库。
PHP7发生了什么变化?
根据其他人的建议,我一直在React的构造函数中绑定类方法,例如:
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
}
Run Code Online (Sandbox Code Playgroud)
我的组件中包含许多方法,并且将所有这些方法都绑定到this。啊,真痛苦!为了避免重复维护此模式,我构建了一个在构造函数中代替所有单独调用的函数;它绑定了特定于该类的所有方法,而父类将照顾自己的方法,将这些类向上移动。例如:
function bindClassMethodsToThis(classPrototype, obj) {
Object.getOwnPropertyNames(classPrototype).forEach(prop => {
if (obj[prop] instanceof Function && prop !== 'constructor') {
obj[prop] = obj[prop].bind(obj);
console.log(`${classPrototype.constructor.name} class binding ${prop} to object`);
}
});
}
class A {
constructor() {
bindClassMethodsToThis(A.prototype, this);
}
cat() {
console.log('cat method');
}
}
class B extends A {
constructor() {
super();
bindClassMethodsToThis(B.prototype, this);
}
dog() {
console.log('dog method');
}
}
let b = new B();
Run Code Online (Sandbox Code Playgroud)
那么,React和ES6专家,这是一种合理的方法,还是我在这里做错了?我应该坚持对此的个人束缚吗?