0

我正在玩新的雅虎 API。我想使用以下地址废弃一些虚拟数据

http://query.yahooapis.com/v1/public/yql?q=desc%20social.updates.search&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=cbfunc

当我运行它时,我得到一个身份验证错误(需要登录到雅虎)这显然对我在互联网上乱搞来说很好。但是,我想从 ruby​​ 脚本中调用它。任何想法我如何进行身份验证?我似乎只能找到一些启用网络的版本。

4

4 回答 4

0

可以尝试omniauth-yahoo授权,但是发现不支持过期获取新token。

于 2012-05-25T03:11:51.750 回答
0

您可以为此尝试使用机械化宝石。我过去曾将它用于其他经过身份验证的服务。

于 2010-04-13T14:00:38.673 回答
0

我还推荐httparty——用它来映射 JSON 服务非常容易。尝试这个:

require 'rubygems'
require 'httparty'

class Yahoo
  include HTTParty
  # i don't think you need auth for this endpoint -- but if you do, uncomment below and fill it in
  #basic_auth 'username', 'password'
  format :json

  def self.load
    self.get 'http://query.yahooapis.com/v1/public/yql', :query => {:q => 'desc social.updates.search', :format => 'json', :diagnostics => true, :env => 'store://datatables.org/alltableswithkeys'}
  end
end

puts Yahoo.load
于 2010-04-13T18:23:52.610 回答
-1

公共函数 ScanColumns(SheetName 作为字符串,thisMany 作为 Double,ShowWhat 作为字符串)

e = 0

For a = 1 To thisMany
    aa = Application.WorksheetFunction.CountA(Sheets(SheetName).Cells(1, a).EntireColumn)
    If aa > 0 Then
        r = a
        If e = 0 Then
            e = a
        End If
    End If
    Next a

    If ShowWhat = "MIN" Then
        ScanColumns = e
    End If
    If ShowWhat = "MAX" Then
        ScanColumns = r
    End If

End Function

Public Function ScanRows(SheetName As String, thisMany As Double, ShowWhat As String)

    e = 0

    For a = 1 To thisMany
        aa = Application.WorksheetFunction.CountA(Sheets(SheetName).Cells(a, 1).EntireRow)
        If aa > 0 Then
            r = a
            If e = 0 Then
                e = a
            End If
        End If
        Next a

        If ShowWhat = "MIN" Then
            ScanRows = e
        End If
        If ShowWhat = "MAX" Then
            ScanRows = r
        End If

    End Function

    Public Function FindInArea(SheetName As String, startRow As String, endRow As String, startCol As String, endCol As String, FindThis As String, ShowWhat As String)

        CalendarMonthFormat1 = "Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec,"
        CalendarMonthFormat2 = "January, Feburary,March,April,May,June,July,August,September,October,November,December,"

        earliestDate = 999999999
        latestDate = 0


        If Left(FindThis, 7) = "[LENGTH" Then
            LengthLook = Replace(FindThis, "[LENGTH", "")
            LengthLook = Replace(LengthLook, "]", "")
        End If


        For a = startRow To endRow
            For b = startCol To endCol
                ThisCell = Sheets(SheetName).Cells(a, b)
                thisCellAddr = Sheets(SheetName).Cells(a, b).Address
                If ThisCell = FindThis Then
                    addrList = addrList & "[" & thisCellAddr & "]"
                    rc_list = rc_list & "[" & a & "," & b & "]"
                    c = c + 1
                End If
                If FindThis = "[MONTHS1]" Then
                    If ThisCell <> "" And InStr(LCase(CalendarMonthFormat1), LCase((ThisCell) & ",")) > 0 And Len(ThisCell) = 3 Then
                        addrList = addrList & "[" & thisCellAddr & "]"
                        rc_list = rc_list & "[" & a & "," & b & "]"
                        c = c + 1
                    End If
                End If
                If FindThis = "[MONTHS2]" Then
                    If ThisCell <> "" And InStr(LCase(CalendarMonthFormat2), LCase((ThisCell) & ",")) > 0 Then
                        addrList = addrList & "[" & thisCellAddr & "]"
                        rc_list = rc_list & "[" & a & "," & b & "]"
                        c = c + 1
                    End If
                End If
                If FindThis = "[DATEFORMAT]" Then
                    If InStr(ThisCell, "/") > 0 Then
                        slash_count = 0
                        For sc = 1 To Len(ThisCell)
                            If Mid(ThisCell, sc, 1) = "/" Then
                                slash_count = slash_count + 1
                            End If
                            Next sc
                            If slash_count = 2 Then
                                On Error Resume Next
                                D = Day(ThisCell)
                                M = Month(ThisCell)
                                Y = Year(ThisCell)
                                If D > 0 And M > 0 And Y > 0 Then
                                    addrList = addrList & "[" & thisCellAddr & "]"
                                    rc_list = rc_list & "[" & a & "," & b & "]"
                                    c = c + 1
                                    If earliestDate > DateValue(ThisCell) Then
                                        earliestDate = DateValue(ThisCell)
                                        If Len(D) = 1 Then
                                            D = "0" & D
                                        End If
                                        If Len(M) = 1 Then
                                            M = "0" & M
                                        End If
                                        eDateLocation = thisCellAddr
                                        eDate_Format = D & "-" & M & "-" & Y
                                    End If

                                    If latestDate < DateValue(ThisCell) Then
                                        latestDate = DateValue(ThisCell)
                                        If Len(D) = 1 Then
                                            D = "0" & D
                                        End If
                                        If Len(M) = 1 Then
                                            M = "0" & M
                                        End If
                                        lDateLocation = thisCellAddr
                                        lDate_Format = D & "-" & M & "-" & Y
                                    End If
                                End If
                            End If
                        End If
                    End If

                    If Left(FindThis, 7) = "[LENGTH" Then
                        If Len(ThisCell) = Val(LengthLook) Then
                            addrList = addrList & "[" & thisCellAddr & "]"
                            rc_list = rc_list & "[" & a & "," & b & "]"
                            c = c + 1
                        End If
                    End If
                    If FindThis = "[DECIMAL]" Then
                        If InStr((ThisCell), ".") > 0 Then
                            addrList = addrList & "[" & thisCellAddr & "]"
                            rc_list = rc_list & "[" & a & "," & b & "]"
                            c = c + 1
                        End If
                    End If
                    If FindThis = "[PERC]" Then
                        If InStr((ThisCell), ".") > 0 And ThisCell <> "" And ThisCell <> 0 And Val(ThisCell) >= -1 And Val(ThisCell) <= 1 Then
                            addrList = addrList & "[" & thisCellAddr & "]"
                            rc_list = rc_list & "[" & a & "," & b & "]"
                            c = c + 1
                        End If
                    End If



                    Next b
                    Next a

                    If ShowWhat = "COUNT" Then
                        FindInArea = c
                    End If
                    If ShowWhat = "ADDR" Then
                        FindInArea = addrList
                    End If
                    If ShowWhat = "RC" Then
                        FindInArea = rc_list
                    End If
                    If ShowWhat = "EARLIESTDATE" Then
                        FindInArea = eDate_Format
                    End If
                    If ShowWhat = "EARLIESTDATEADDR" Then
                        FindInArea = eDateLocation
                    End If
                    If ShowWhat = "LATESTDATE" Then
                        FindInArea = lDate_Format
                    End If
                    If ShowWhat = "LATESTDATEADDR" Then
                        FindInArea = lDateLocation
                    End If
                End Function
于 2016-10-16T06:14:54.517 回答