samuelfa/g-trends 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samuelfa/g-trends

Composer 安装命令:

composer require samuelfa/g-trends

包简介

Google Trends API for PHP

README 文档

README

Google Trends API for PHP

Introduction

This is an unofficial Google Trends API for PHP.

Please notice that the good functionality of this API depends on Google's willing to keep the backward compatibility and/or the parameters, naming and/or required values.
If this happens, feel free to contribute or open an issue.

Requirements

Please see the composer.json file.

Installation

Via Composer (require)

If you have composer installed globally

$ composer require x-fran/g-trends

If you use composer.phar local

# Get your own copy of composer.phar
$ curl -s https://getcomposer.org/installer | php -- --filename=composer
$ composer require "x-fran/g-trends": "^1.0"

Via Composer (create-project)

You can use the create-project command from Composer to create the project in one go (you need to install composer):

$ curl -s https://getcomposer.org/installer | php -- --filename=composer
$ composer --no-dev create-project x-fran/g-trends path/to/install

Via Git (clone)

First, clone the repository:

$ git clone https://github.com/x-fran/g-trends.git # optionally, specify the directory in which to clone
$ cd path/to/install
$ curl -s https://getcomposer.org/installer | php -- --filename=composer

At this point, you need to use Composer to install dependencies. Assuming you already have Composer:

$ composer --no-dev install

Demo

To see a demo output from all methods (okay, functions) please open in your favorite browser the index.php

Usage

New instance of the class GTrends

# This options are by default if none provided
$options = [
        'hl'  => 'en-US',
        'tz'  => -60, # last hour
        'geo' => 'IE',
    ];
$gt = new GTrends($options);

Interest Over Time

print_r($gt->interestOverTime('Dublin'));

Related Queries

# You can add up to 5 keywords
print_r( $gt->relatedQueries(['Dublin', 'Madrid', 'Paris']));

Trending Searches

# p54 is Google's tricky and wired code for Ireland
print_r($gt->trendingSearches('p54', date('Ymd')));

Interest by Subregion

# You can add up to 5 keywords
# Parameter $resolution (optional) for United States 'Subregion', 'Metro', 'City'
# Parameter $resolution (optional) for the rest of the countries 'Subregion', 'City' only
print_r($gt->relatedQueries(['Dublin'], 'City'));

Top Charts

# Parameters
# date '201708' for September 2017
# cid (category id) only able to choose from those listed on https://www.google.com/trends/topcharts
print_r($gt->topCharts('201708', 'basketball_players'));

Suggestions Autocomplete

print_r($gt->suggestionsAutocomplete('toys'));

Common API parameters

$keyWordList (Array)

Array of keywords (up to 5) to get data for

$category (Integer)

Search by category Please view this wiki page containing all available categories

$tz (Integer)

Timezone Offset For example US CST is 360

$time (String)

Timezone Offset

'now 1-H' would get data from last hour (default)
'today 2-d' would get data from today to 2 days ago
'today 3-m' would get data from today to 3 months ago
'today 4-y' would get data from today to 4 years ago

Caveats

- This is not an official or supported API
- Rate Limit is not publicly known, let me know if you have a consistent estimate.

Credits

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 47
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固