nativerank/silktide-semrush-api 问题修复 & 功能扩展

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

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

nativerank/silktide-semrush-api

Composer 安装命令:

composer require nativerank/silktide-semrush-api

包简介

SEMrush API client

README 文档

README

This repository has been forked from the Silktide/semrush-api repository and been made available on Packagist so to allow Pagekit to install it as a dependency.

There has been a single change to the code base in the ResponseParser that's diverged this fork from the main API.

As such, the name of the project in the composer.json has been changed from 'silktide/semrush-api' to 'nativerank/silktide-semrush-api' to define the creator of the API, but make it specific to Nativeranks needs.

Build Status Code Climate Test Coverage

A PHP API client for the SEMrush API.

Supported actions:

  • domain_ranks
  • domain_rank
  • domain_rank_history
  • domain_organic
  • domain_adwords
  • domain_adwords_unique

Usage

Installation

composer require silktide/semrush-api
composer update

Setup

This library was designed to use Dependency Injection (DI). If you don't use DI, you could use the factory to set up the API client:

$client = \Silktide\SemRushApi\ClientFactory::create("[YOUR SEMRUSH API KEY]");

Caching

The API library can use a cache to reduce calls to the API. This library comes with an in-memory cache:

$cache = new \Silktide\SemRushApi\Cache\MemoryCache();
$client->setCache($cache);

You can also write your own cache using the provided CacheInterface (\Silktide\SemRushApi\Cache\CacheInterface).

API calls

Domain ranks

Getting the SEMrush "domain_ranks" for a website:

$result = $client->getDomainRanks('silktide.com');

Domain rank

Getting the SEMrush "domain_rank" for a website:

    $result = $client->getDomainRank(
        'silktide.com', 
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

Domain rank history

Getting the SEMrush "domain_rank_history" for a website:

    $result = $client->getDomainRankHistory(
        'silktide.com', 
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

Domain organic

Getting the SEMrush "domain_organic" for a website:

    $result = $client->getDomainOrganic(
        'silktide.com', 
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

Domain adwords

Getting the SEMrush "domain_adwords" for a website:

    $result = $client->getDomainAdwords(
        'silktide.com', 
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

Domain adwords unique

Getting the SEMrush "domain_adwords_unique" for a website:

    $result = $client->getDomainAdwordsUnique(
        'silktide.com', 
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

Using options

Here's an example of passing options to the domain ranks action in order to return a specific set of columns.

$result = $client->getDomainRanks('silktide.com', [
    'export_columns' => [
        \Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_BUDGET,
        \Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_KEYWORDS,
        \Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_TRAFFIC
     ]
]);

Using results

All API actions will return a Result object. Result objects contain a number of Row objects and are iterable and countable. Here's a (non exhaustive) example of how they can be used.

foreach ($result as $row) {
    $budget = $row->getValue(\Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_BUDGET);
    echo "\nThe AdWords spend of this site in the last month was an estimated ${$budget}";
}

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2016-05-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固