{"id":19210342,"url":"https://github.com/seniverse/seniverse-api-demos","last_synced_at":"2025-04-06T04:14:35.239Z","repository":{"id":52657899,"uuid":"78628514","full_name":"seniverse/seniverse-api-demos","owner":"seniverse","description":"心知天气 API 产品使用调用示例","archived":false,"fork":false,"pushed_at":"2021-04-22T01:34:32.000Z","size":179,"stargazers_count":244,"open_issues_count":2,"forks_count":191,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-30T03:07:39.046Z","etag":null,"topics":["api","demo","jsonp","seniverse","thinkpage"],"latest_commit_sha":null,"homepage":"https://docs.seniverse.com/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seniverse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-11T10:31:44.000Z","updated_at":"2025-03-13T17:58:59.000Z","dependencies_parsed_at":"2022-08-22T00:21:36.785Z","dependency_job_id":null,"html_url":"https://github.com/seniverse/seniverse-api-demos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fseniverse-api-demos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fseniverse-api-demos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fseniverse-api-demos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fseniverse-api-demos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seniverse","download_url":"https://codeload.github.com/seniverse/seniverse-api-demos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430963,"owners_count":20937875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","demo","jsonp","seniverse","thinkpage"],"created_at":"2024-11-09T13:35:47.391Z","updated_at":"2025-04-06T04:14:35.105Z","avatar_url":"https://github.com/seniverse.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 心知天气 API 调用示例\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors)\n\n请首先查看心知天气的[文档](https://docs.seniverse.com)来了解心知天气 API 的调用方式，以下是一些不同编程语言的示例代码，也欢迎给此项目提 PR 来添加更多不同语言的调用示例，同时也可以向心知天气申请以获得[开发者认证](https://blog.seniverse.com/2290)。\n\n## 代码示例\n\n- [JavaScript](./javascript)\n\n  - [直接调用](./javascript/index.html)\n  - [JSONP](./javascript/jsonp.html)\n\n- [Node.js](./nodejs)\n\n  - [使用更安全的签名验证方式（荐）](./nodejs/lib/api.js)\n  - [心知官方 Node.js package（支持 Typescript）](https://github.com/seniverse/seniverse-api)\n\n- [Python](./python)\n\n  - 直接调用\n\n    - [urllib](./python/demo-urllib.py)\n    - [requests](./python/demo-requests.py)\n\n  - [使用更安全的签名验证方式（荐）](./python/demo-jsonp.py)\n\n- [PHP](./php)\n\n  - [使用更安全的签名验证方式（荐）](./php/demo-jsonp.php)\n  - [PHP demo, contributed by open source community](./php/demo.php)\n\n- [Java](./java)\n\n- [Swift4](./swift)\n\n- [Object-C](./oc)\n\n- [Common Lisp](./common-lisp)\n\n  - [使用更安全的签名验证方式（荐）](./common-lisp/seniverse-demo.lisp)\n  - [cl-seniverse-api ( Lisp SDK )](https://github.com/muyinliu/cl-seniverse-api)\n\n- [Elixir](./elixir)\n\n**注意**：所有代码示例仅做开发参考使用，不要在生产环境下暴露 key！生产环境下请通过后端进行签名验证。\n\n## 常见问题\n\n1. 我在本地调试的时候，如何进行域名绑定？\n\n   本地调试时，请在 [控制台 -\u003e 产品管理](https://www.seniverse.com/account) 的对应产品页面将域名绑定填写为：`127.0.0.1`。若 `127.0.0.1` 在本机无法访问，请注意是否开启了全局代理。\n\n1. 为什么我绑定了 `127.0.0.1` 但访问时报错（没有找到域名，或者报跨域请求的错误，常见于纯前端 API 调用时）？\n\n   **请通过 `127.0.0.1` 的链接，通过 jsonp 的形式访问，而不是 `localhost`，`localhost` 访问会跨域。**\n\n   **请通过 `127.0.0.1` 的链接，通过 jsonp 的形式访问，而不是 `localhost`，`localhost` 访问会跨域。**\n\n   **请通过 `127.0.0.1` 的链接，通过 jsonp 的形式访问，而不是 `localhost`，`localhost` 访问会跨域。**\n\n1. 关于 API 调用问题\n\n   为了保证您账号的安全，不要纯前端进行 API 调用！仅仅通过前端调用会造成您的 `uid` 和 `key` 暴露，可能会带来不必要的麻烦。推荐的调用方式有：\n\n   - 后端进行 API 调用获取数据后交给前端渲染\n   - 或者后端构造 JSONP 形式的请求链接，交给前端调用\n\n1. 关于 API 调用失败的问题\n\n   可能的原因有：\n\n   - `ttl` 有效时间过短\n   - `key` 加密后的结果没有通过 Base64 编码\n   - 在构造签名的时候，参数的顺序不正确。参与签名的参数有 UNIX 时间戳 `ts`，签名失效时间 `ttl`（单位为秒，缺省为 1800，可选）和公钥 `uid`。请确保：\n     1. 参数按照键字典升序排列，例如 `ts=1443079775\u0026ttl=300\u0026uid=U123456789` 或者 `ts=1443079775\u0026uid=U123456789`\n     2. `ts` 和 `ttl` 的单位都是秒\n   - **Last but not least，请将 demo 内的 API key 等参数替换为自己账户的数据**\n\n## 其他第三方相关项目\n\n- JavaScript\n  - [seniverse-jsonp](https://github.com/seanhuai/seniverse-jsonp)\n\n## Contributors\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore --\u003e\n\u003ctable\u003e\u003ctr\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/muyinliu\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/3318872?v=4\" width=\"100px;\" alt=\"muyinliu\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003emuyinliu\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/seniverse/seniverse-api-demos/commits?author=muyinliu\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://www.mokeyjay.com/\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/6757507?v=4\" width=\"100px;\" alt=\"mokeyjay\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003emokeyjay\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/seniverse/seniverse-api-demos/commits?author=mokeyjay\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"http://cv.flyingant.me/\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/1773209?v=4\" width=\"100px;\" alt=\"Liu Cheng a.k.a MaYi\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eLiu Cheng a.k.a MaYi\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/seniverse/seniverse-api-demos/commits?author=flyingant\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/wuqingzheng\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/11942361?v=4\" width=\"100px;\" alt=\"dazheng_wu\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003edazheng_wu\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/seniverse/seniverse-api-demos/commits?author=wuqingzheng\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/hewiez\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/26524421?v=4\" width=\"100px;\" alt=\"hewieZ\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ehewieZ\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/seniverse/seniverse-api-demos/commits?author=hewiez\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/weishuaigithub\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/21059908?v=4\" width=\"100px;\" alt=\"weishuaigithub\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eweishuaigithub\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/seniverse/seniverse-api-demos/commits?author=weishuaigithub\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"http://weibo.com/longwosion\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/203458?v=4\" width=\"100px;\" alt=\"Eric SHI\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eEric SHI\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#maintenance-longwosion\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://hacknical.com\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/10706318?v=4\" width=\"100px;\" alt=\"ecmadao\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eecmadao\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#maintenance-ecmadao\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"http://maples7.com/\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/9960982?v=4\" width=\"100px;\" alt=\"Maples7\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMaples7\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#maintenance-Maples7\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseniverse%2Fseniverse-api-demos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseniverse%2Fseniverse-api-demos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseniverse%2Fseniverse-api-demos/lists"}