定制 serphouse/serphouse-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

serphouse/serphouse-php

Composer 安装命令:

composer require serphouse/serphouse-php

包简介

Automate your search engines (Google, Bing, Yahoo) result (serp api) using Serphouse.com API client and retrive in structured JSON format.

README 文档

README

Packagist License Packagist Downloads GitHub Actions Workflow Status GitHub Actions Workflow Status GitHub Actions Workflow Status

SERPHouse API is the starting point on your journey towards building a powerful SEO software. With SERPHouse you can get all the data you’d need to build an efficient application while also saving your time and your budget.

This comprehensive document designed to provide you with all the technical information as well as product information you need to interact with our API and harness its full potential. Whether you're a software developer integrating SERPHouse SERP API services into your application or a curious user exploring the possibilities, this API documentation will serve as your go-to resource.

High Volume SERP API for SEO professionals and data scientist. We built reliable, accurate and cost efficient solution, We take cares of resolving captcha, managing proxy to ensure you get reliable Structured JSON data.

This API supported Serphouse's standard REST API that accepts/returns JSON requests. Here is the API reference

Get started

Using the Serphouse API wrapper for PHP is straightforward. Follow these steps to integrate it into your project:

Documentation

Documentation for Serphouse's API and its usage is available at https://docs.serphouse.com/

Prerequisites

  • PHP >= 7.2

Installation

You can install the Serphouse PHP package via Composer. Run the following command in your project directory:

composer require serphouse/serphouse-php

Usage

you need to load the dependency in your script.

<?php
require __DIR__ . '/vendor/autoload.php';
?>

After installing the package, you can set up the Serphouse client in your code like this:

<?php

use Serphouse\SERPHouseClient;

$serphouse = new SERPHouseClient('YOUR_API_KEY');

Replace 'YOUR_API_KEY' with your actual Serphouse API key.

Get API Key

You can obtain an API key by registering at https://app.serphouse.com/register. This key will be required for accessing the API.

Examples

  1. Serp Api

  2. Domains List

  3. Languages List

  4. Locations List

  5. Account Info

  6. Trend Api

Serp Api

1. SERP Live

$serphouse->serpApi->live([
    'data' => [
        'q' => 'apple',
        'domain' => 'google.com',
        'lang' => 'en',
        'device' => 'desktop',
        'serp_type' => 'web',
        'loc' => 'Alba,Texas,United States',
        'loc_id' => '1026201',
        'verbatim' => '0',
        'gfilter' => '0',
        'page' => '1',
        'num_result' => '10',
    ],
]);

If you need to get response by responseType HTML or Json then you can use Like Below Example:

$serphouse->serpApi->live('DATA_ARRAY','responseType'); // default responseType is Json

2. SERP Schedule

$serphouse->serpApi->schedule([
    "data" => [
        [
            "q" => "Coffee",
            "domain" => "google.com",
            "lang" => "en",
            "device" => "desktop",
            "serp_type" => "web",
            "loc" => "Alba,Texas,United States",
            "verbatim" => 0,
            "postback_url" => "Webhook_url",
            "pingback_url" => "Webhook_url",
            "page" => 1,
            "num_result" => 10
        ]
    ]
]);

3. SERP Check

$serphouse->serpApi->check('SERP_ID');

4. SERP Get

$serphouse->serpApi->get('SERP_ID');

If you need to get response by responseType HTML or Json then you can use like below example:

$serphouse->serpApi->get('SERP_ID','responseType'); // default responseType is Json

Domains List

1. Get Domains List

$serphouse->domains->list();

Languages List

1. Get Languages List

$serphouse->languages->list();

If you need to get Languages List by google, bing and yahoo then you can use like below example:

$serphouse->languages->list(['type'=> 'bing']); // default type is google

Locations List

1. Get Locations List

$serphouse->location->search(['q'=> 'texas']);

If you need to get Locations List by google, bing and yahoo then you can use like below example:

$serphouse->languages->search(['q'=> 'texas','type'=> 'bing']); // default type is google

Account Info

1. Get Account Information

$serphouse->account->fetch();

Trend Api

1. Trend Search

$serphouse->trends->search([
    'time_zone_offset' => '-330',
    'keywords' => 'google,youtube',
    'time' => 'now 1-d',
    'property' => 'youtube',
    'category' => '0',
    'geo' => 'us',
    'language_code' => 'en'
]);

2. Trend Schedule

$serphouse->trends->schedule([
    "data" => [
        [
            "time_zone_offset" => -330,
            "keywords" => "google",
            "time" => "now 1-d",
            "property" => "youtube",
            "category" => 0,
            "geo" => "us",
            "language_code" => "en",
            "postback_url" => "Webhook_url",
            "pingback_url" => "Webhook_url"
        ]
    ]
]);

3. Get TimeZone List

$serphouse->trends->timeZoneList();

4. Get Categories List

$serphouse->trends->categoryList();

5. Get Country and State List

$serphouse->trends->countryStateList();

6. Get Language List

$serphouse->trends->languageList();

7. Trends Check

$serphouse->trends->check('TRENDS_ID');

8. Trends Get

$serphouse->trends->get('TRENDS_ID');

Response

Example of success response.

SERPHouse\Services\Handlers\Responses Object
(
    [statusCode:SERPHouse\Services\Handlers\Responses:private] => 200
    [response:SERPHouse\Services\Handlers\Responses:private] => {"status":"success","msg":"Completed","search_metadata":{"id":128078258,"status":"success","created_at":"2024-05-04T06:20:10.000000Z","processed_at":"2024-05-04 06:20:10"},"search_parameters":{"langauge_code":"en-US","geo":"US","keywords":"google,youtube","time_zone_offset":"-330","time":"now 1-d","category":0,"property":"youtube"},"results":{"TIMESERIES":[{"time":"1714716960","formattedTime":"May 3, 2024 at 11:46 AM","formattedAxisTime":"May 3 at 11:46 AM","value":[19,72],"hasData":[true,true],"formattedValue":["19","72"]}],"GEO_MAP":{"google":{"default":{"geoMapData":[{"geoCode":"US-VT","geoName":"Vermont","value":[100],"formattedValue":["100"],"maxValueIndex":0,"hasData":[true]}]}},"youtube":{"default":{"geoMapData":[{"geoCode":"US-NH","geoName":"New Hampshire","value":[100],"formattedValue":["100"],"maxValueIndex":0,"hasData":[true]}]}}},"RELATED_QUERIES":{"google":{"default":{"rankedList":[{"rankedKeyword":[{"query":"google link","value":100,"formattedValue":"100","hasData":true,"link":"/trends/explore?q=google+link&date=now+1-d&geo=US"}]},{"rankedKeyword":[{"query":"the man who killed google search","value":1650,"formattedValue":"+1,650%","link":"/trends/explore?q=the+man+who+killed+google+search&date=now+1-d&geo=US"}]}]}},"youtube":{"default":{"rankedList":[{"rankedKeyword":[{"query":"on youtube","value":100,"formattedValue":"100","hasData":true,"link":"/trends/explore?q=on+youtube&date=now+1-d&geo=US"}]},{"rankedKeyword":[{"query":"jayson tatum youtube channel","value":5300,"formattedValue":"Breakout","link":"/trends/explore?q=jayson+tatum+youtube+channel&date=now+1-d&geo=US"}]}]}}}}}
    [errorMessage:SERPHouse\Services\Handlers\Responses:private] => 
)

Example of validation errors response.

SERPHouse\Services\Handlers\Responses Object
(
    [statusCode:SERPHouse\Services\Handlers\Responses:private] => 400
    [response:SERPHouse\Services\Handlers\Responses:private] => {"status":"error","msg":"validation_error","error":{"time_zone_offset":["The time zone offset field is required."]}}
    [errorMessage:SERPHouse\Services\Handlers\Responses:private] => Client error: `POST https://api.serphouse.com/trends/search` resulted in a `400 Bad Request` response:
{"status":"error","msg":"validation_error","error":{"time_zone_offset":["The time zone offset field is required."]}}
)

You need to manage the response.

  • get response status code using getStatusCode() function

    $response->getStatusCode()
  • get response using getResponse() function and you will get Json string

    $response->getResponse()
  • get error message using getErrorMessage() function and you will get Json string

    $response->getErrorMessage()

Exception Classes

SERPHouseNotFoundException

This exception is thrown when the requested call is not found.

SERPHousePaymentRequiredException

This exception is thrown when payment is required to access the requested call.

SERPHouseRateLimitExceededException

This exception is thrown when the rate limit for API requests has been exceeded in the SERP House API. For more information about rate limit check this https://docs.serphouse.com/introduction/rate-limits

SERPHouseServerErrorException

This exception is thrown when there is an internal server error.

SERPHouseUnauthorizedException

This exception is thrown when the request is unauthorized to access the requested call or Invalid API Key.

serphouse/serphouse-php 适用场景与选型建议

serphouse/serphouse-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 447 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「curl」 「json」 「xml」 「rest」 「api」 「client」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 serphouse/serphouse-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 serphouse/serphouse-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 serphouse/serphouse-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-06