twitter-php-ads-sdk icon indicating copy to clipboard operation
twitter-php-ads-sdk copied to clipboard

missing opertor_type on Targeting Criteria creation

Open itayalon opened this issue 4 years ago • 5 comments

Hi, We updated to the new version and while setting the Targeting Criteria during Line item creation we get this error:

"MISSING_PARAMETER: operator_type is a required parameter"

A quick look into twitter's changelog reveals that they enforce a new required parameter for that endpoint.

right now we are adding it manually but can you add it please?

itayalon avatar Feb 15 '21 11:02 itayalon

Hi @itayalon

I understand,

You mean making it available in TargetingCriteriaFields class, right?

Thanks

hborras avatar Feb 15 '21 14:02 hborras

Hi @hborras, thanks for the quick reply yes it seems like it should be added to TargetingCriteriaFields and also to TargetingCriteria as a value in $properties array + setter and getter.

itayalon avatar Feb 16 '21 08:02 itayalon

did you find a clean way to add it manually to the request? I'm interested

decaluwepatrick avatar Mar 19 '21 13:03 decaluwepatrick

Hi decaluwepatrick, what we ended up doing as a temp solution is to extend the TargetingCriteria class and add operator_type to properties. then, we set the operator type in the line creation flow (e.g setOperatorType('EQ'))

i attach the class extension code

`<?php

namespace AppBundle\Vendors\Twitter\Campaign;

use Hborras\TwitterAdsSDK\TwitterAds;

class TargetingCriteria extends \Hborras\TwitterAdsSDK\TwitterAds\Campaign\TargetingCriteria { protected $operator_type;

public function __construct($id = null, TwitterAds $twitterAds = null)
{
    $this->properties[] = 'operator_type';

    parent::__construct($id, $twitterAds);
}

/**
 * @return mixed
 */
public function getOperatorType()
{
    return $this->operator_type;
}

/**
 * @param mixed $operator_type
 */
public function setOperatorType($operator_type): void
{
    $this->operator_type = $operator_type;
}

}`

itayalon avatar Mar 21 '21 10:03 itayalon

thanks, makes complete sense

decaluwepatrick avatar Mar 21 '21 19:03 decaluwepatrick