tacman / bing-news-search
PHP Library for bing news search API.
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.0.1
- symfony/cache: ^7.2
- symfony/cache-contracts: ^3.5
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.5
- rector/rector: ^2.0
- spaze/phpstan-disallowed-calls: ^4.0
This package is auto-updated.
Last update: 2025-01-04 01:25:17 UTC
README
Fork of https://github.com/gabriel-yuji-inoue/BingNewsSearch
This fork drops support for PHP 7 and refactors how structures are populated. It is used by the survos/bing-news-bundle.
See more of this API at: https://docs.microsoft.com/en-us/bing/search-apis/bing-news-search
Dependencies
- PHP 8.3+
- GuzzleHttp 7.0.x >
Instalation
composer require tacman/bing-news-search
composer config repositories.bing_news '{"type": "vcs", "url": "git@github.com:tacman/BingNewsSearch.git"}' composer require tacman/bing-news-search:dev-refactor
composer config repositories.bing_news '{"type": "path", "url": "~/g/tacman/BingNewsSearch"}' composer require tacman/bing-news-search:*@dev
Usage of Api bing NEWS microsoft an easy way
Initialize the Client instance
$client = new Client( 'apibingurl.com.br', // https://api.bing.microsoft.com/ 'your_secret_key' // a1b2c3d4e5f6g7h8a1b2c3d4e5f6g7h8 );
Configure client
$client->enableExceptions(); // throw exceptions for debug $client->disableSsl(); // disable Guzzle verification SSL
Search by category
// Ex: Search by business category, with pt_BR language, without safe search restriction; $request = $client->category() ->get(Enum\Category::BUSINESS(), Enum\Language::PT_BR()) ->setSafeSearch(Enum\SafeSearch::OFF()) ->request(); $news = $request->getNews();
Search by key word
// Ex: Search by key word, limited at 50 items, with safe search restriction; $request = $client->search() ->get('something cool') ->setQuantity(50) ->setSafeSearch(Enum\SafeSearch::STRICT()) ->request(); $news = $request->getNews();
Search by trending topics
// Ex: Get trending topics news, with en_US language. $request = $client->trending() ->get(Enum\Language::EN_US()) ->request(); $news = $request->getTrending();
MORE
Check BingNewsSearch\Enum classes to know all avaiables search configurations, such as: Categories and SubCategories, Languages and more..