emergentmethods / asknews-php-sdk
AskNews API
0.2.16
2024-09-22 11:33 UTC
Requires
- php: ^8.0 || ^8.1 || ^8.2 || ^8.3
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
README
AskNews API
安装与使用
要求
PHP 8.0 及更高版本。
Composer
要通过 Composer 安装绑定,请在 composer.json
中添加以下内容
{ "repositories": [ { "type": "vcs", "url": "https://github.com/emergentmethods/asknews-php-sdk.git" } ], "require": { "emergentmethods/asknews-php-sdk": "*@dev" } }
然后运行 composer install
手动安装
下载文件并包含 autoload.php
<?php require_once('/path/to/asknews-php-sdk/vendor/autoload.php');
入门指南
请按照 安装过程 进行操作,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure sdk credentials $config = new AskNews\Configuration([ 'clientId' => 'YOUR_ASKNEWS_CLIENT_ID', 'clientSecret' => 'YOUR_ASKNEWS_CLIENT_SECRET', 'scopes' => ['news', 'chat', 'stories', 'analytics'] ]); $apiInstance = new AskNews\Api\AnalyticsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $asset = 'asset_example'; // string | The asset name to query for sentiment. $metric = 'news_positive'; // string | The metric to obtain. Weighted metrics account for page-rank of original source. Higher page rank sources are weighted more heavily. $date_from = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | The start date in ISO format $date_to = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | The end date in ISO format try { $result = $apiInstance->getAssetSentiment($asset, $metric, $date_from, $date_to); print_r($result); } catch (Exception $e) { echo 'Exception when calling AnalyticsApi->getAssetSentiment: ', $e->getMessage(), PHP_EOL; }
API 端点
所有 URI 都相对于 https://api.asknews.app
模型
- AbcAPIErrorModel1
- AbcAPIErrorModel10
- AbcAPIErrorModel11
- AbcAPIErrorModel12
- AbcAPIErrorModel13
- AbcAPIErrorModel14
- AbcAPIErrorModel15
- AbcAPIErrorModel16
- AbcAPIErrorModel17
- AbcAPIErrorModel18
- AbcAPIErrorModel19
- AbcAPIErrorModel2
- AbcAPIErrorModel20
- AbcAPIErrorModel21
- AbcAPIErrorModel22
- AbcAPIErrorModel23
- AbcAPIErrorModel24
- AbcAPIErrorModel25
- AbcAPIErrorModel26
- AbcAPIErrorModel27
- AbcAPIErrorModel28
- AbcAPIErrorModel29
- AbcAPIErrorModel3
- AbcAPIErrorModel30
- AbcAPIErrorModel31
- AbcAPIErrorModel32
- AbcAPIErrorModel33
- AbcAPIErrorModel34
- AbcAPIErrorModel35
- AbcAPIErrorModel36
- AbcAPIErrorModel4
- AbcAPIErrorModel5
- AbcAPIErrorModel6
- AbcAPIErrorModel7
- AbcAPIErrorModel8
- AbcAPIErrorModel9
- 文章
- AsknewsApiErrorsAPIErrorModel
- AsknewsApiSchemaV1CommonGraphRelationships
- AsknewsApiSchemaV1StoriesGraphRelationships
- BodyBuildGraph
- 选择
- 分类
- 聚类概率
- 大陆
- 创建聊天完成请求
- 创建聊天完成请求消息
- 创建聊天完成请求消息1
- 创建聊天完成响应
- 创建聊天完成响应1
- 创建聊天完成响应选择
- 创建聊天完成响应选择1
- 创建聊天完成响应流
- 创建聊天完成响应流1
- 创建聊天完成响应流选择
- 创建聊天完成响应流选择1
- 创建聊天完成响应使用情况
- 创建聊天完成响应使用情况1
- 显示图片URL
- 域名URL
- 实体
- 过滤参数
- 金融响应
- 金融响应时间序列
- 金融响应时间序列数据
- 预测响应
- 图形响应
- HTTPValidationError
- 簇内统计
- 关键人物
- 列表模型响应
- 模型项
- 偏移
- PingModel
- Reddit评论
- Reddit实体
- Reddit观点
- Reddit响应
- Reddit线程
- 报告声音
- 搜索响应
- 搜索响应字典项
- 情感
- 源报告项
- 停止
- 故事响应
- 故事响应
- 故事更新
- 故事更新显示图片URL内部
- 用户
- 验证错误
- 验证错误项
- 验证错误位置内部
- 验证错误模型
- 值
- 网络搜索响应
- 网络搜索结果
授权
- 类型:
OAuth
- 流程:
client_credentials
- 授权 URL:
https://auth.asknews.app/oauth2/auth
- 作用域:
- chat: 聊天相关操作
- news: 新闻相关操作
- analytics: 分析相关操作
- stories: 故事相关操作
- profile: 个人资料相关操作
- reddit: Reddit 相关操作
- forecast: 预测相关操作
在 AskNews API 文档 中查找完整详情。
支持
加入我们的Discord,查看其他人正在构建的内容,并获得您项目支持。