小编use*_*287的帖子

在2012年11月,通过json和php获取youtube数据的正确语法是什么?

我很难通过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/developers_guide_protocol_understanding_video_feeds#Understanding_Video_Entries

条目的内容:

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

代码示例(根据要求)

所以我在做的是:

  • 我有一张表格
  • 提交后,它由php文件(insert.php)处理
  • 这会对数据进行一些更改,然后提交到数据库
  • 我在$ final_li_code开头的行中得到错误消息(但是如果没有包含json变量,则代码有效,所以问题在于json变量)
  • (我被告知这种形式很容易被sql注入,但它不是一个面向公众的形式,即它是受htaccess/htpasswd保护的).

这是insert.php的相关代码:

// basic form information
$field1 …
Run Code Online (Sandbox Code Playgroud)

php syntax json youtube-api

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

如何在特定的<ul>类中找到所有<li>?

环境:

美丽的汤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)

python beautifulsoup python-2.7

3
推荐指数
1
解决办法
2万
查看次数

将Gmail与OAuth和Nodemailer结合使用的确定方式是什么?

期望的行为

使用GmailOAuth2Nodemailer从服务器端发送电子邮件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/

上述资源的说明中存在空白,并且一些信息已过时,因此下面的答案是我的最终实现,此方法似乎有效。

我正在发布此解决方案以确认这是最佳做法,如果可以的话,可以节省其他人的时间。

node.js oauth-2.0 nodemailer

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

如何在Fedora 19中安装MariaDB?

我是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

fedora mariadb

2
推荐指数
2
解决办法
6715
查看次数

Apache mod_wsgi在OpenShift Online上寻找的切入点是什么?

我有一个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/

在OpenShift上找不到WSGI应用程序

理想情况下,我试图理解这些文件的执行顺序及其功能:

  • /wsgi/application
  • /wsgi/my-bottle-application
  • setup.py
  • setup.pyc
  • setup.pyo

UPDATE

这表明入口点是wsgi/application:

https://github.com/openshift/origin-server/search?utf8=%E2%9C%93&q=OPENSHIFT_PYTHON_WSGI_APPLICATION

我仍然有兴趣了解上述文件的执行顺序以及它执行的确切内容setup.py和方式 - 即没有对它的引用,application所以如何"调用"?

mod-wsgi python-2.7 openshift

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

如何在Google Apps脚本中更改页面设置从纵向到横向的方向?

我通过Google Apps脚本生成文档.

有没有办法来改变Page setup...> OrientationPortraitLandscape

该文档包含仅在Landscape模式下显示的表格,我希望能够:

  • 生成文档
  • 改变从纵向到横向的方向
  • 将文档转换为PDF并发送给用户

转换为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)

google-apps-script

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

何时使用btoa(),atob(),encodeURIComponent()和decodeURIComponent()?

你什么时候用?

它们应该一起使用,例如:

atob(encodeURIComponent(...))
Run Code Online (Sandbox Code Playgroud)

如果没有,何时将btoa()atob()使用,当将encodeURIComponent()decodeURIComponent()使用?

javascript browser encoding

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

如何在 google apis explorer 中定义 API Key?

我只是在以下位置测试 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

为了:

  • 启用 Google Sheets API
  • 创建 API 密钥

因此,我有:

  • 客户编号
  • 客户机密
  • API 密钥

Try this API>Credentials部分,有两个复选框:

  • 谷歌 OAuth 2.0
  • API 密钥

我尝试uncheckGoogle OAuth 2.0选项,这样我可以使用刚刚发出请求API Key-但我看不到,我可以进入API Key

在此处输入图片说明

如何在Try this API部分中定义 API 密钥,以便我可以仅使用API Key(而不是Google OAuth 2.0 )发出请求。

google-apis-explorer google-sheets-api

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

C#中浮点数和双数据类型的实际范围是多少?

我正在学习C#并试图在C#中获得实际数据类型范围的逻辑视觉表示.

我已经移动了整数,现在浮动和双数据类型.

  1. 8位(1字节),sbyte,-128到127.
  2. 8位(1字节),字节,0到255.
  3. 16位(2字节),短,-32,768到32,767.
  4. 16位(2字节),ushort,0到65535.
  5. 32位(4字节),int,-2,147,483,648到2,147,483,647.
  6. 32位(4字节),uint,0到4,294,967,295.
  7. 64位(8字节),长,-9,223,372,036,854,775,808到9,223,372,036,854,775,807
  8. 64位(8字节),ulong,0到18,446,744,073,709,551,615.

以下是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# floating-point double types

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

Console.ReadLine()没有在C#中保持控制台打开

我正在学习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# console.readline

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