locked
PHP API AdGroup ID format RRS feed

  • Question

  • Hi guys, is there anyone who supports PHP Bing API library? 

    I have a problem with Adgroup ID formats.

    First of all, with "AddAdGroupsRequest" I'm gettings such result in "$response->AdGroupIds->long[0]":

    float 1.1368950466744E+15

    Which equals to "1136895046674400". But real ID is "1136895046674416", so we're losing two last digits here.

    Going further, when trying to add some Ad's with "AddAdsRequest", I'm always getting "The AdGroup ID is invalid" message because the library converts such long ID's as above to integer, which results in 2147483647 number, which seems to be largest positive value of a signed integer in 32-bit systems.

    Here is code from the library, file 'bingads/v10/CampaignManagementClasses.php':

        /**
         * Adds one or more ads to an ad group.
         * @link http://msdn.microsoft.com/en-us/library/dn277506(v=msads.100).aspx AddAds Request Object
         * 
         * @uses Ad
         * @used-by BingAdsCampaignManagementService::AddAds
         */
        final class AddAdsRequest
        {
            /**
             * The identifier of the ad group to add the ads to.
             * @var integer
             */
            public $AdGroupId;
    
            /**
             * An array of ads to add to the specified ad group.
             * @var Ad[]
             */
            public $Ads;
        }

    How could $AdGroupId be integer? Maybe it's just because of my local environment? But I use 64-bit OS and PHP-5.6-x64.
    Looking forward to your reply, thanks.

    Thursday, December 22, 2016 5:32 AM

Answers

  • Hello.

    I can confirm the AdGroupId is a 'long' from the service standpoint i.e. as defined in the singleWsdl and documented on MSDN

    Regarding the max int size on your local machine I found the following in the PHP manual.

    "The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18, except on Windows prior to PHP 7, where it was always 32 bit. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, maximum value using the constant PHP_INT_MAX since PHP 5.0.5, and minimum value using the constant PHP_INT_MIN since PHP 7.0.0."

    Also you might need both 64-bit PHP and 64-bit hardware for native 64-bit integers. If your local environment does not support it, will it work if you cast the AdGroupIds result of AddAdGroups to float array instead?

    Best regards,

    Eric

    Thursday, December 22, 2016 4:03 PM

All replies

  • Ok, actually I managed to create and Ad from another environment, but how to get proper AdGroup ID from AddAdGroupsRequest is still a question.
    Thursday, December 22, 2016 9:00 AM
  • Hello.

    I can confirm the AdGroupId is a 'long' from the service standpoint i.e. as defined in the singleWsdl and documented on MSDN

    Regarding the max int size on your local machine I found the following in the PHP manual.

    "The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18, except on Windows prior to PHP 7, where it was always 32 bit. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, maximum value using the constant PHP_INT_MAX since PHP 5.0.5, and minimum value using the constant PHP_INT_MIN since PHP 7.0.0."

    Also you might need both 64-bit PHP and 64-bit hardware for native 64-bit integers. If your local environment does not support it, will it work if you cast the AdGroupIds result of AddAdGroups to float array instead?

    Best regards,

    Eric

    Thursday, December 22, 2016 4:03 PM
  • Thanks, I've checked ad group creation on other environment and it's ID was type casted to "int". So that is definitely problem of my local setup.
    Thursday, December 22, 2016 8:06 PM