如何开始使用 oauth for YQL 来获取历史股票数据? [英] How do I get started with oauth for YQL for historical stock data?

查看:73
本文介绍了如何开始使用 oauth for YQL 来获取历史股票数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我搜索市场数据提要时,我被带到了雅虎金融的 YQL.它看起来很棒,而且对于公共使用/查询非常简单,但是公共版本的每日限制对于我的需求来说太小了..我有我的雅虎 ID 来开始使用 oauth,但是我找不到任何好的例子与我正在尝试做的事情有关...

in my search for a market data feed, I've been led to YQL for yahoo finance. It looks great, and very simple for the public use/ queries, but the daily limit for the public version is too small for my needs.. I got my yahoo ID to get started with oauth, but I can't find any good examples pertaining to what I'm trying to do...

我想使用我的 C# 桌面应用程序登录",然后继续下载感兴趣的数据.如何使用誓言维度?作为参考点,我的背景是使用 html 敏捷包进行简单的屏幕抓取,我从未有过任何 Web 服务经验.任何人都可以让我开始.我现在被卡住了(并且整个星期都在做这个).提前致谢...

I'd like to "sign in" with my desktop app in C#, and proceed to download data of interest. How do I use the oath dimension? My background as a point of reference is simple screen- scraping with the html agility pack, I've never had any experience with web services. Can anyone get me started. I'm stuck at the moment (and have been all week on this). Thanks in advance...

推荐答案

在这种情况下,您访问的是公共数据(而不是用户私有数据),因此您将使用 OAuth 两条腿授权.YDN 站点上的此页面是不同数据类型的良好起点:Private数据 v 公共数据.

In this case you are accessing public data (as opposed to user private data), so you'll be using OAuth two-legged authorization. This page on the YDN site is a good starting point for the different data types: Private Data v Public Data.

两条腿意味着您需要以某种方式(使用您的应用程序密钥和秘密)签署您的请求,但没有用户授权步骤.OAuth 签名通常很棘手,因此大多数人会使用 OAuth 库.

Two-legged means you need to sign your request a certain way (with your application key & secret), but there is no user-authorization step. OAuth signing is usually tricky, so most people will use an OAuth library.

YQL 代码示例 页面说明了这一点.向下滚动到查询公共数据"部分,查看使用签名的两条腿请求调用 YQL 的示例.

There is a good walk-through on the YQL Code Examples page that illustrates this. Scroll down to the "Querying Public Data" section to see examples of calling YQL with a signed two-legged request.

<?php
include_once("yosdk/lib/Yahoo.inc");

define("API_KEY","your-api-key-here");
define("SHARED_SECRET","your-secret-here");
YahooLogger::setDebug(true);

$twoleg = new YahooApplication (API_KEY, SHARED_SECRET);
$query = "select * from yahoo.finance.historicaldata where symbol =\"YHOO\" and startDate = \"2011-12-01\" and endDate = \"2011-12-04\"";
$results = $twoleg->query ($query);
print_r ($results);

运行上面的代码会得到一些历史股票数据,如:

Running the above code gives some historical stock data like:

[quote] => Array
    (
        [0] => stdClass Object
            (
                [date] => 2011-12-02
                [Date] => 2011-12-02
                [Open] => 16.31
                [High] => 16.41
                [Low] => 16.03
                [Close] => 16.05
                [Volume] => 22714500
                [Adj_Close] => 16.05
            )

        [1] => stdClass Object
            (
                [date] => 2011-12-01
                [Date] => 2011-12-01
                [Open] => 16.42
                [High] => 16.46
                [Low] => 16.09
                [Close] => 16.23
                [Volume] => 47059800
                [Adj_Close] => 16.23
            )

    )

当然,您是在询问 C#,但希望这可以为您提供有关所需内容的更多背景知识.我会为 C# 搜索两条腿的 OAuth 解决方案 - 这个问题看起来有一些有效的答案:有人使用 DNOA 实现了 2 Legged OAuth 吗?.

Of course you're asking about C#, but hopefully this gives you more background on what will be needed. I would search for two-legged OAuth solutions for C# - this question looks to have some working answers: Has anybody implemented 2 Legged OAuth using DNOA?.

这是另一种可能的解决方案,一种为您执行两条腿 OAuth 签名的 Web 服务:OAuth 验证:YQL 的 2-legged OAuth 服务.

Here's another possible solution, a web service that does the two-legged OAuth signing for you: OAuth-ify this: 2-legged OAuth service for YQL.

这篇关于如何开始使用 oauth for YQL 来获取历史股票数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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