Skip to content

Set SERP HTML tasks

georgesvash edited this page Nov 6, 2018 · 4 revisions

Set SERP HTML tasks

Original docs can be found at https://docs.dataforseo.com/#setting-serp-html-tasks

Attention Please notice that the get() method isn't used. The static call ::getAfterMerge() is used instead. Note that the first setOpt() call should be static

Method: ::getAfterMerge($pool) - creates a single payload out of the list of objects, makes a single call to the API, whereas the payload contains arrays with postIds or without, and returns an object ResponseCollection

Use case with several arrays in the payload.

require_once '../vendor/autoload.php';

use DFSClient\DFSClient;
use DFSClient\Models\SERP_API\SettingsExtraSerpTasks;

$DFSClient = new DFSClient('Your Login','Your Password');
$model     = new SettingsExtraSerpTasks();

$pool=[]; // array with objects.

for($i=0; $i<3; $i++){
    $pool[] = $model::setOpt('priority', 1)
        ->setOpt('se_id', 22 )
        ->setOpt('loc_id', 1006886)
        ->setOpt('key_id', 1095202)
        ->setPostId($i); //- you can use postId method, if you want set custom id for payload array.
}


// run request to api.
$completed = SettingsExtraSerpTasks::getAfterMerge($pool);

if (!$completed->isSuccessful())
    dd($completed);

foreach ($completed as $key=>$item){
    dump($item);
}

Getting Started

  1. Home
  2. Installation
  3. Configuration
  4. Base Usage
  5. Response Collection
  6. Abstract Model

DataForSEO APIs

Clone this wiki locally