A PHP library for Twingly's Search API (previously known as Analytics API). Twingly is a blog search service that provides a searchable API known as Twingly Search API.
Install via Composer
php composer.phar require twingly/twingly-search
# Or if you have installed composer globally
composer require twingly/twingly-search
use Twingly\Client;
$client = new Client();
$query = $client->query();
$query->search_query = 'github page-size:10 lang:sv';
$result = $query->execute();
foreach($result->posts as $post) {
echo $post->url . "\n";
}
The twingly-search
library talks to a commercial blog search API and requires an API key. Best practice is to set the TWINGLY_SEARCH_KEY
environment variable to the obtained key. \Twingly\Client
can be passed a key at initialization if your setup does not allow environment variables.
This library is documented with phpdoc. To generate documentation call
phpdoc -d ./src -t ./docs
Example code can be found in examples/.
To learn more about the capabilities of the API, please read the Twingly Search API documentation.
- API key, sign up via twingly.com to get one
- PHP 7.x, 8.x
Install PHP and Composer, on OS X:
brew install [email protected]
brew install composer
Install project dependencies:
composer install
Run tests:
./vendor/bin/phpunit
Run examples:
TWINGLY_SEARCH_KEY=<KEY> php examples/hello_world.php
twingly-search
is released on Packagist.
-
Bump the version in Client.php, follow Semantic Versioning 2.0.0.
-
Create a tag with the same version and push it to GitHub:
git tag <VERSION> && git push --follow-tags
-
You're done! (This repo has a GitHub service hook that notifies Packagist when a new version is created.)
- Install GitHub Changelog Generator if you don't have it
gem install github_changelog_generator
- Set
CHANGELOG_GITHUB_TOKEN
to a personal access token to increase your GitHub API rate limit - Generate the changelog
github_changelog_generator
The MIT License (MIT)
Copyright (c) 2016 Twingly AB
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.