小编lin*_*iii的帖子

尝试从YouTube <iframe>捕获console.log消息

YouTube HTML5视频<iframe>会针对各种事件(如加载广告横幅)触发console.log消息.我正在尝试以编程方式使用JavaScript捕获console.log消息以触发函数,如下所示:

console['log'] = function(msg){
    // Operate on msg
}
Run Code Online (Sandbox Code Playgroud)

要向YouTube发送console.log消息<iframe>,可使用以下方法(以简写为参考):

document.getElementsByTagName('iframe')[youTubeIframe].contentWindow.console.log(msg);
Run Code Online (Sandbox Code Playgroud)

但是,以下代码不起作用:

document.getElementsByTagName('iframe')[youTubeIframe].contentWindow.console['log'] = function(msg){
    // Operate on msg from YouTube <iframe>
}
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

window.console = document.getElementsByTagName('iframe')[youTubeIframe].contentWindow.console;
console['log'] = function(msg){
    // Operate on msg
}
Run Code Online (Sandbox Code Playgroud)

我不明白的是; 如果我能够向YouTube调用console.log消息<iframe>,那么如何捕获控制台日志消息?如果有这样的方法,这样做的正确方法是什么?

javascript youtube iframe

5
推荐指数
1
解决办法
1304
查看次数

如何使用PHP SDK和Graph API将事件发布到Facebook粉丝专页?

以下代码有效,但它将事件创建为当前登录的页面管理员.我需要它将事件发布到粉丝页面本身.仅供参考:我的应用程序已被授予权限范围:manage_pages

<?php

// Initialize a Facebook instance from the PHP SDK
$config = array(
  'appId' => FACEBOOK_APP_ID,
  'secret' => FACEBOOK_APP_SECRET,
  'cookie' => false,
  'scope' => 'manage_pages,create_event'
);

$facebook = new Facebook($config);

$access_token = $facebook->getAccessToken();

$page_id = 'XXXXXXXXXXXX';

// Now, getting the PAGE Access token, using the user access token

$page_token_url = "https://graph.facebook.com/$page_id?fields=access_token&" . $access_token;
$response = file_get_contents($page_token_url);

// Parse the return value and get the Page access token
$resp_obj = json_decode($response,true);

$page_access_token = $resp_obj['access_token'];

// Declare the variables we'll …
Run Code Online (Sandbox Code Playgroud)

php facebook-graph-api facebook-php-sdk

5
推荐指数
1
解决办法
2899
查看次数

从 Google Docs 文档(不是 Sheets 电子表格)读取 JSON 的 URL 格式

我知道从 Google Sheets 电子表格读取 JSON 的 URL 格式,如下所示:

https://spreadsheets.google.com/feeds/cells/[sheet_id]/[sheet_number]/public/basic?alt=json
Run Code Online (Sandbox Code Playgroud)

是否有类似的 URL 格式可以从 Google Docs 文档读取 JSON 数据?

google-docs

1
推荐指数
1
解决办法
654
查看次数