2017 © Pedro Peláez
 

library webhoseio-php

Webhose.io PHP SDK

image

webhose/webhoseio-php

Webhose.io PHP SDK

  • Tuesday, April 18, 2017
  • by rangeva
  • Repository
  • 5 Watchers
  • 7 Stars
  • 204 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 1 Versions
  • 44 % Grown

The README.md

webz.io client for PHP

A simple way to access the Webz.io API from your PHP code:, (*1)

// API Key from: https://webz.io/dashboard
Webz::config("API_KEY");

//Perform a "filterWebContent" query using "United States" as our keywords.
$params = array("q"=>"United States", "size"=>"3");
$result = Webz::query("filterWebContent", $params);

//Fetch the next results using the same terms.
$result = Webz::get_next();

API Key

To make use of the webz.io API, you'll need an API key., (*2)

To get one, sign up at: https://webz.io/auth/signup, (*3)

And your key will be available here: https://webz.io/dashboard, (*4)

Usage

To get started, you'll need to import the class and configure it with your API key:, (*5)

require_once('webz.php');

// API Key from: https://webz.io/dashboard
Webz::config("API_KEY");


, (*6)

API Endpoints, (*7)

The first parameter the query() function accepts is the API endpoint string. Available endpoints: * filterWebContent - access to the news/blogs/forums/reviews API * productFilter - access to data about eCommerce products/services * darkFilter - access to the dark web (coming soon), (*8)

Now you can make a request and inspect the results:, (*9)

//Helper method to print result:
function print_filterwebdata_titles($api_response)
{
    if($api_response == null)
    {
        echo "

Response is null, no action taken., (*10)

"; return; } if(isset($api_response->posts)) foreach($api_response->posts as $post) { echo "

" . $post->title . ", (*11)

"; } } //Perform a "filterWebContent" query using "United States" as our keywords. $params = array("q"=>"United States", "size"=>"3"); $result = Webz::query("filterWebContent", $params); print_filterwebdata_titles($result);

You can traverse the structure as you would any PHP array:, (*12)

//Print more detailed information about the article:

$params = array("q"=>"United States", "size"=>"1");
$result = Webz::query("filterWebContent", $params);

foreach($result->posts as $post)
{
    echo "

Site: " . $post->thread->site . ", (*13)

"; echo "

Categories:, (*14)

"; echo "
    "; foreach($post->thread->site_categories as $category) { echo "
  • " . $category . "
  • "; } echo "
"; }


, (*15)

Depending on the endpoint used, the resulting JSON array could provide "posts", "products", ... You can view the JSON in the browser to get a clearer picture of the return data. In order to view the data in the browser, we can enable a debug flag to expose the URL fed to cURL:, (*16)

//If true, echoes the parameterised Webz API URL before executing request.
Webz::enable_debug(true);

Full documentation

  • Webz::config(api_key), (*17)

    • api_key - your API key
  • Webz::query(end_point_str, params), (*18)

    • end_point_str
    • filterWebContent - access to the news/blogs/forums/reviews API
    • productFilter - access to data about eCommerce products/services
    • darkFilter - access to the dark web (coming soon)
    • params: A key value dictionary. Read about the available parameters.
  • Webz::get_next() - Fetches the next page of results using the same parameters., (*19)

  • Webz::enable_debug(debug_enabled), (*20)

    • debug_enabled - boolean, If true, echoes the parameterised Webz API URL before executing requests.

Polling

It is possible to continue a search to fetch more results using the same parameters:, (*21)

//Perform a "productFilter" query using "United Kingdom" as our keywords.
$params = array("q"=>"United Kingdom", "size"=>"1");
$result = Webz::query("productFilter", $params);
print_productsearch_titles($result);

//Fetch the next results using the same terms.
$result = Webz::get_next();
print_productsearch_titles($result);

$result = Webz::get_next();
print_productsearch_titles($result);

//...
//When $result is null, there are no more results available.

License

The code of this repository is published under the MIT license, (*22)

The Versions

18/04 2017

dev-master

9999999-dev https://github.com/Webhose/webhoseio-PHP

Webhose.io PHP SDK

  Sources   Download

GPL-2.0+

The Requires

  • php ^5.4|^7.0
  • ext-curl *
  • ext-libxml *