jovix/dataforseo-clientv3

DataForSeo 的 PHP 客户端

v1.2.5 2024-09-05 12:38 UTC

This package is auto-updated.

Last update: 2024-09-05 12:43:56 UTC


README

logo

这是一个 DataForSEO API 的 PHP 客户端库。该库描述了用于操作 API 端点的模型。随着新端点的添加,库将进行更新。

需求

PHP 7.3 及更高版本

安装

composer require jovix/dataforseo-clientv3

使用方法

在简单版本中,您的应用程序应如下所示

public
   config.php
   index.php
vendor
 composer.json
 composer.lock

config.php 文件包含

<?php  
return $config = [  
   'DATAFORSEO_LOGIN' => 'login',  
   'DATAFORSEO_PASSWORD' => 'password',  
   'timeoutForEachRequests' => 120,  
   'apiVersion' => '/v3/',  
   'url' => 'https://api.dataforseo.com',  
 // You can set extra paths for Entities  
 // For all entity we use namespace: DFSClientV3\Entity\Custom
 // Last index will have the priority
   'extraEntitiesPaths' => [  
      'your full path to extra entity',  
      'your full path to extra entity'  
  ],  
];

index.php 文件包含

<?php  
include_once '../vendor/autoload.php';  
  
$client = new DFSClientV3\DFSClient();  
$client->setConfig('config.php');  
  
// You will receive detailed information about your API usage  
$model = new \DFSClientV3\Models\CommonApi\User();  
// You can get an object whose essence is described in the appropriating entity 
// (attention, may contain outdated data)
$res = $model->get();  
print_r($res);  
// You can get the JSON answer  
$res = $model->getAsJson();  
print_r($res);  
  
  
// You will receive SERP data specific to the indicated keyword, search engine, and location parameters
$model = new \DFSClientV3\Models\SerpApi\SettingSerpLiveAdvanced();  
$model->setSe("google");  
$model->setSeType("organic");  
$model->setKeyword("seo");  
$model->setLocationCode(2840);  
$model->setLanguageCode("en");  
$res = $model->getAsJson();  
print_r($res);

API 文档

https://docs.dataforseo.com/v3