firebase - 访问 HackerNews API
问题描述
我正在尝试访问 HackerNews API 来练习围棋。
每当我去我的本地主机尝试查看 Firebase 数据库(存储数据的地方)的输出时,我都会遇到一个 Google 帐户身份验证表单。
对此的任何帮助将不胜感激。在我的终端中,我使用 curl 检查是否收到了来自服务器的响应。我收到了 200 OK 的内容响应。
我以为我可能缺少 Firebase 客户端库,但我不确定这是否是现在的问题。
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
response, err := http.Get("https://hacker-news.firebaseio.com/v0/item/8863.json")
if err != nil {
fmt.Printf("The http request failed with the error %s\n", err)
} else {
data, _ := ioutil.ReadAll(response.Body)
fmt.Fprintf(w, string(data))
}
}
func main() {
fmt.Println("Starting the applicaiton")
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}
解决方案
您不打算添加.json
到 URL(通过https://github.com/HackerNews/API)吗?
例如https://hacker-news.firebaseio.com/v0/item/8863.json
推荐阅读
- google-apps-script - Code.gs 之外的 Google 表格的 Google Apps 脚本自定义函数?
- sql - Wordpress 无法识别 SQL 数据库
- java - 在 Java 中反序列化 C# 生成的 RabbitMQ 消息
- javascript - JavaScript shuffle 算法解释
- python - 如何在python中有效地存储一个非常大的列表
- javascript - 检查 x 元素是否在网页中的完整视图中
- c++ - 双打意味着除加?
- python-3.x - 我需要获取过去 12 个月中每个月的所有日子的文章,但我的月份和年份都错了?
- firebase - firebase 实时数据库统一包是否支持通用 Windows 平台构建?
- serilog - 使用 serilog 创建扩展名为 .bak 的日志备份文件