I'm trying to upload an image from my computer to my Portfolio in ET using PHP. I'm having some trouble because I'm not sure how to set the URN and Source properly and I'm not finding any clues on the help section at ET's website. My code so far is:

    $wsdl = 'https://webservice.exacttarget.com/etframework.wsdl ';

    try {

        $client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
        $client->username = 'myUsername';
        $client->password = 'myPassword';

        $port = new ExactTarget_Portfolio();
        $port->DisplayName = 'API Uploaded Test v10';
        $port->CustomerKey = 'API Uploaded Test v10';
        $rs = new ExactTarget_ResourceSpecification();  
        $rs->URN = 'http://email.exacttarget.com/myFolder/myFile.jpg'; //not sure if this is right
        $port->Source = $rs;
        $port->FileName = 'myFile.jpg'; //file in the same folder as the php file
        $object = new SoapVar($port, SOAP_ENC_OBJECT, 'Portfolio', "http://exacttarget.com/wsdl/partnerAPI ");

        $request = new ExactTarget_CreateRequest();
        $request->Options = NULL;
        $request->Objects = array($object);

        $results = $client->Create($request);

    } catch (SoapFault $e) {

Also, I'm getting the warning:

Warning: DOMDocument::loadXML(): xmlns:ns2: 'http://exacttarget.com/wsdl/partnerAPI ' is not a valid URI in Entity

but that URI is working on other methods like lists and data extensions.

Anyone has experience doing this kind of stuff and can give me some directions?



You have a space at the end of the url in:

$object = new SoapVar($port, SOAP_ENC_OBJECT, 'Portfolio', "http://exacttarget.com/wsdl/partnerAPI ");

Delete this line

$port->FileName = 'myFile.jpg'; //file in the same folder as the php file

you cannot set FileName in CreateRequest for Portfolio, system will decide the FileName from Source.URN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.