emergentmethods / asknews-php-sdk
AskNews API
0.2.23
2024-11-23 13:04 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
Installation & Usage
Requirements
PHP 8.0 and later.
Composer
To install the bindings via Composer, add the following to composer.json
:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/emergentmethods/asknews-php-sdk.git" } ], "require": { "emergentmethods/asknews-php-sdk": "*@dev" } }
Then run composer install
Manual Installation
Download the files and include autoload.php
:
<?php require_once('/path/to/asknews-php-sdk/vendor/autoload.php');
Getting Started
Please follow the installation procedure and then run the following:
<?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 Endpoints
All URIs are relative to https://api.asknews.app
Models
- 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
- AbcAPIErrorModel37
- AbcAPIErrorModel38
- AbcAPIErrorModel39
- AbcAPIErrorModel4
- AbcAPIErrorModel40
- AbcAPIErrorModel5
- AbcAPIErrorModel6
- AbcAPIErrorModel7
- AbcAPIErrorModel8
- AbcAPIErrorModel9
- Article
- AsknewsApiErrorsAPIErrorModel
- AsknewsApiSchemaV1CommonGraphRelationships
- AsknewsApiSchemaV1StoriesGraphRelationships
- BodyBuildGraph
- Choice
- Classification
- ClusterProbabilities
- Continent
- CreateChatCompletionRequest
- CreateChatCompletionRequestMessage
- CreateChatCompletionRequestMessage1
- CreateChatCompletionResponse
- CreateChatCompletionResponse1
- CreateChatCompletionResponseChoice
- CreateChatCompletionResponseChoice1
- CreateChatCompletionResponseStream
- CreateChatCompletionResponseStream1
- CreateChatCompletionResponseStreamChoice
- CreateChatCompletionResponseStreamChoice1
- CreateChatCompletionResponseUsage
- CreateChatCompletionResponseUsage1
- DisplayImageUrl
- DomainUrl
- Entities
- FilterParams
- FinanceResponse
- FinanceResponseTimeSeries
- FinanceResponseTimeSeriesData
- ForecastResponse
- GeoCoordinate
- GraphResponse
- HTTPValidationError
- IntraClusterStatistics
- KeyPerson
- ListModelResponse
- ModelItem
- Offset
- Offset1
- Offset2
- Offset3
- PingModel
- Profile
- ProfileResponse
- RedditComment
- RedditEntities
- RedditPerspective
- RedditResponse
- RedditThread
- ReportingVoice
- ReportingVoice1
- SearchResponse
- SearchResponseDictItem
- Sentiment
- ServiceAccountProfile
- SourceReportItem
- Stop
- StoriesResponse
- StoryResponse
- StoryUpdate
- StoryUpdateDisplayImageUrlsInner
- ThreadId
- User
- UserProfile
- UserProfileSubscription
- ValidationError
- ValidationErrorItem
- ValidationErrorLocInner
- ValidationErrorModel
- Value
- WebSearchResponse
- WebSearchResult
Authorization
- Type:
OAuth
- Flow:
client_credentials
- Authorization URL:
https://auth.asknews.app/oauth2/auth
- Scopes:
- chat: Chat related operations
- news: News related operations
- analytics: Analytics related operations
- stories: Stories related operations
- profile: Profile related operations
- reddit: Reddit related operations
Find full details at the AskNews API documentation.
Support
Join our Discord to see what other people are building, and to get support with your projects.