0

I am using this api end to post user in audience list id(which i am creating dynamically).

Here is code i am using -:

        require '../vendor/autoload.php';
        require 'config.php';


        $api =  TwitterAds::init(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret);

        $responseAcc = $api->get('accounts');   
        $account = $responseAcc->getBody();
        $twAdsAccId = $account->data[0]->id;


        $response = $api->post('accounts/'.$twAdsAccId.'/tailored_audiences',array('name'=>'Test'));
        $newAudiDat = $response->getBody();
        $audienceId = $newAudiDat->data->id;

        $userJson = '{             
                       {
                          "users": [
                            {
                              "email": [
                                "c88a2aba7408c019ea7e721832cc89aeec2f91169872a977fbbe46d642c8fdd9"
                              ]
                            }
                          ]
                        }               
                    }';

          $responseAudieUser =$api->post('accounts/'.$twAdsAccId.'/tailored_audiences/'.$audienceId.'/users',array('operation_type'=>'Update','params'=> $userJson));

But when I am printing the response it is showing error :-

            caught exception 'Hborras\TwitterAdsSDK\TwitterAds\Errors\ServerError' with message 'SERVER_ERROR' in /opt/lampp/htdocs/demo/tweets-php/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:501

I think I am passing parameter in wrong way so i searched but did not get any lead .

Note -: All parameters are sent in the request body and a Content-Type of application/json is required (Please see).

1 Answers1

0

Here Hector, maintainer of this project

Could you create a new Issue here : https://github.com/hborras/twitter-php-ads-sdk/issues ?

Meantime I'll try to see what is happening

Thanks!

hborras
  • 13
  • 6