我很难通过json和php获取youtube视频数据.
我花了整整一个晚上和早上尝试从网络上的代码片段和堆栈溢出.
他们没有工作的事实告诉我,我没有使用最新的语法.
我认为提出这个问题的最明确的方法是询问以下属性是否正确,如2012年11月.
所以这是我的初始变量声明:
$json = file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$random_text}?v=2&alt=json");
$json_data = json_decode($json);
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我,如果以下是正确的:
1. $video_title = $json_data->{'entry'}->{'title'};
2. $video_date = $json_data->{'entry'}->{'published'};
3. $video_duration = $json_data->{'entry'}->{'media:group'}->{'yt$duration'};
4. $video_views = $json_data->{'entry'}->{'yt$statistics'}->{'viewCount'};
5. $video_description = $json_data->{'entry'}->{'content'};
Run Code Online (Sandbox Code Playgroud)
我不想通过提供太多其他代码和信息来淡化问题,但我得到的错误之一是:
Catchable fatal error: Object of class stdClass could not be converted to string
Run Code Online (Sandbox Code Playgroud)
所以我知道其中一个属性是不正确的.
谢谢你的帮助,我要去喝咖啡然后回来吧!
研究
这些资源是我想要获得的属性的直接api引用,应该可以工作,但它们似乎不是:(.
饲料和进入结构:
条目的内容:
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_entry
标题标签:
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_title
发布标签:
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_published
yt:持续时间标签:
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_yt:duration
yt:statistics> viewCount标签:
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_yt:statistics
内容标签(视频说明):
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_content
代码示例(根据要求)
所以我在做的是:
这是insert.php的相关代码:
// basic form information
$field1 …Run Code Online (Sandbox Code Playgroud) 环境:
美丽的汤4
Python 2.7.5
逻辑:
'find_all' <li>实例位于<ul>a类中,my_class例如:
<ul class='my_class'>
<li>thing one</li>
<li>thing two</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
澄清:只需获取<li>标签之间的"文本" 即可.
Python代码:
(下面的find_all不正确,我只是把它放在上下文中)
from bs4 import BeautifulSoup, Comment
import re
# open original file
fo = open('file.php', 'r')
# convert to string
fo_string = fo.read()
# close original file
fo.close()
# create beautiful soup object from fo_string
bs_fo_string = BeautifulSoup(fo_string, "lxml")
# get rid of html comments
my_comments = bs_fo_string.findAll(text=lambda text:isinstance(text, Comment))
[my_comment.extract() for my_comment in my_comments]
my_li_list …Run Code Online (Sandbox Code Playgroud) 期望的行为
使用Gmail,OAuth2并Nodemailer从服务器端发送电子邮件node.js文件。
我尝试过的
相关文件
https://nodemailer.com/smtp/oauth2
https://nodemailer.com/usage/using-gmail
https://developers.google.com/gmail/api/auth/web-server
相关问题
使用OAuth2和nodemailer从我的Gmail帐户发送电子邮件
如何在没有用户干预的情况下授权应用程序(网络或已安装)?
/sf/answers/3355544461/
/sf/answers/1580094351/
上述资源的说明中存在空白,并且一些信息已过时,因此下面的答案是我的最终实现,此方法似乎有效。
我正在发布此解决方案以确认这是最佳做法,如果可以的话,可以节省其他人的时间。
我是Linux和VirtualBox的新手,但是我已经在Windows 7上通过VirtualBox设置了一个访客Fedora 19机器(32位,因为我没有VT-x功能),并且我想安装MariaDB.我也是MariaDB的新手,但可以在MySQL命令行中完成基本操作.
我能找到的最具权威性的帖子是:
http://fedoraproject.org/wiki/Features/ReplaceMySQLwithMariaDB https://fedoraproject.org/wiki/QA:Testcase_Installing_MariaDB_in_f19
但是它们似乎有不同的说明和"设置MariaDB存储库"功能:
https://downloads.mariadb.org/mariadb/repositories/
似乎没有包含选择Fedora 19的选项.
所以我的问题是在Fedora 19中安装MariaDB所需的确切步骤是什么?
我是键,校验和和repo等术语的新手,所以如果步点可以显示在点点列表中会很棒.
编辑:在下面的链接中还有一篇文章,几乎让我超越理解线,但我希望确认和澄清步骤:
http://www.bytebot.net/blog/archives/2013/04/30/testing-fedora-19
我有一个OpenShift Python 2.7我猜测用的应用程序mod_wsgi.
是否可以ssh到OpenShift Online并查看.conf位于以下位置的文件:
/etc/apache2/sites-available/
Run Code Online (Sandbox Code Playgroud)
我想看看.wsgiApache在WSGIScriptAlias中定义的文件.
也许它只是寻找/wsgi/application?
一些帖子表明最近对Python应用程序的结构进行了更改,但它们可能不会影响我的旧版本:
如何在Python 3.3盒中更改或覆盖openshift.conf
https://blog.openshift.com/openshift-online-march-2014-release-blog/
理想情况下,我试图理解这些文件的执行顺序及其功能:
/wsgi/application /wsgi/my-bottle-application setup.pysetup.pycsetup.pyoUPDATE
这表明入口点是wsgi/application:
https://github.com/openshift/origin-server/search?utf8=%E2%9C%93&q=OPENSHIFT_PYTHON_WSGI_APPLICATION
我仍然有兴趣了解上述文件的执行顺序以及它执行的确切内容setup.py和方式 - 即没有对它的引用,application所以如何"调用"?
我通过Google Apps脚本生成文档.
有没有办法来改变Page setup...> Orientation从Portrait到Landscape?
该文档包含仅在Landscape模式下显示的表格,我希望能够:
转换为PDF并发送
// create the document
var doc = DocumentApp.create('Sample Document - Landscape Mode');
var body = doc.getBody();
// add lots of content...
// ensure all content is added to the PDF
// see: https://stackoverflow.com/a/44481513/1063287
doc.saveAndClose();
// create the pdf file
var pdf_file = doc.getAs("application/pdf");
// see: https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)
GmailApp.sendEmail('user@test.com', 'Attachment example', 'Please see the attached file.', {
attachments: [pdf_file],
name: 'Test Name'
}); …Run Code Online (Sandbox Code Playgroud) 你什么时候用?
它们应该一起使用,例如:
atob(encodeURIComponent(...))
Run Code Online (Sandbox Code Playgroud)
如果没有,何时将btoa()和atob()使用,当将encodeURIComponent()与decodeURIComponent()使用?
我只是在以下位置测试 Google Sheets API:
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
我正在使用该Try this API部分填写请求参数并执行请求(向工作表追加一行)。
我遵循了Step 1这里:
https://developers.google.com/sheets/api/quickstart/js
为了:
因此,我有:
在Try this API>Credentials部分,有两个复选框:
我尝试uncheck了Google OAuth 2.0选项,这样我可以使用刚刚发出请求API Key-但我看不到,我可以进入的API Key。
如何在Try this API部分中定义 API 密钥,以便我可以仅使用API Key(而不是Google OAuth 2.0 )发出请求。
我正在学习C#并试图在C#中获得实际数据类型范围的逻辑视觉表示.
我已经移动了整数,现在浮动和双数据类型.
以下是msdn中float和double数据类型大小的引用:
Float:http://msdn.microsoft.com/en-us/library/b1e65aza( v= vs.110).aspx

双倍:http: //msdn.microsoft.com/en-us/library/678hzkk9.aspx

因此,试图遵循上面编号列表中指定实际数字范围的惯例,这两个范围实际上代表什么?
我正在学习C#(VS 2012 Professional),在下面的示例中,即使该Console.ReadLine()方法是代码块中的最后一条指令,控制台窗口也不会保持打开状态:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace testing
{
class Program
{
static void Main(string[] args)
{
// fahrenheit conversion example
Console.Write("Enter temp in fahrenheit: ");
double fahrenheit = Console.Read();
double celsius = (fahrenheit - 32.0) * (5.0 / 9.0);
Console.WriteLine("Celsius is: " + celsius);
Console.ReadLine();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在Console.ReadLine()方法的实现中是否存在复杂性,或者代码块中可能存在冲突的代码?
c# ×2
python-2.7 ×2
browser ×1
double ×1
encoding ×1
fedora ×1
javascript ×1
json ×1
mariadb ×1
mod-wsgi ×1
node.js ×1
nodemailer ×1
oauth-2.0 ×1
openshift ×1
php ×1
python ×1
syntax ×1
types ×1
youtube-api ×1