Rohea / OpenXApiClient

PHP5 and PSR-0 compatible port of OpenX XML-RPC API (v2) client. This is a work in progress!!!
GNU General Public License v2.0
12 stars 9 forks source link

Invalid request payload error #2

Open kadnan opened 10 years ago

kadnan commented 10 years ago

On adding banner I get Invalid request error. Code is given below:

 $bannerInfo = array(    'bannerId' => (int)$bannerId,
                                       'campaignId' => (int)$campaignId,
                                       'bannerName' => $bannerName,
                                      // 'storageType' => 'string',
                                       'imageURL' => $imageURL,
                                       'htmlTemplate' => '',
                                       'width'  => 0,
                                       'height' => 0,
                                       'weight' => 0,
                                       'target' => '_blank',
                                       'url' => $url,
                                       'bannerText' => $bannerText,
                                       'status' => (int)$status,
                                      // 'adserver' => 'string',
                                       'transparent' => 0,
                                      // 'capping' => 'integer',
                                      // 'sessionCapping' => 'integer',
                                      // 'block' => 'integer',
                                       'aImage' => $aImage,
                                     //  'aBackupImage' => 'custom',
                                       'comments' => $comments,
                                       'alt' => $alt,
                                       'filename' => $filearray['name'],
                                      // 'append' => 'string',
                                      // 'prepend' => 'string',
                                       );

It throws following exception:

Invalid request payload: xmlrpc element NIL cannot be child of VALUE

mbeccati commented 10 years ago

That's what I do in a project that uses this api client:

use fXmlRpc\Client,
    fXmlRpc\ExtensionSupportInterface,
    fXmlRpc\Serializer\XmlWriterSerializer;

use OpenXApiClient\OpenXApiClient;

...

        $serializer = new XmlWriterSerializer;
        $serializer->disableExtension(ExtensionSupportInterface::EXTENSION_NIL);
        $client = new Client($url, null, null, $serializer);
        return new OpenXApiClient($client, $user, $pass);
mbeccati commented 10 years ago

When I have some time, I'll speak to @Rohea about fixing some remaining bugs and moving the project to the Revive Adserver repo.

kadnan commented 10 years ago

I am not getting how is it related with my issue? any workaround of my problem? is it issue at OpenX RPC end? Is there anyway I can print XML payload?

mbeccati commented 10 years ago

The OpenX/Revive API doesn't support NIL elements. That's why I disable them in the serializer of the client.

kadnan commented 10 years ago

But what Element is actually goin Nil? I did paste the array structure I am sending. What am I missing?

mbeccati commented 10 years ago

There are quite a few things commented out, so all of them maybe? ;)

kadnan commented 10 years ago

Right, one of my dev friend was working on it, I will take care of it and test myself with payload. How do I know what fields re necessary to send and what not?

mbeccati commented 10 years ago

There's currently no APi doc available, so you can either do trial & error or look up the Revive source code. But then agin, you'd currently need something like the above in order to avoid having to send the optional fields.

TomiS commented 10 years ago

@mbeccati You can grab this under the Revive project namespace whenever you want. Probably you want to rename from OpenX to Revive at the same time too? We also have a reference to this in Packagist.org so just let me know when you wish to do the change and I'll do what I can to make sure people find the official version.

HasanJuniad commented 9 years ago

My problem was solved by following NEW 'storageType' =>'html', //'url' => $url, //'comments' => $comments, //'alt' => $alt OLD 'storageType' =>'img', 'url' => $url, 'comments' => $comments, 'alt' => $alt