function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kasuokasuo 

Chatter and php

Do you have an example of php code I can used to update the chatter current status ?

Thank you !

Best Answer chosen by Admin (Salesforce Developers) 
AkoAko

Just figured it out. I was using an old version of the partner WSDL file (pre-Chatter). Update it to the current one and it should work!

All Answers

Kasu0Kasu0

This code is wrong:   

 

    $mySforceConnection = new SforcePartnerClient();
    $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
    $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
   
   
    $fieldsToUpdate = new DOMDocument('1.0', 'iso-8859-1');

    $statusElement=$fieldsToUpdate->createElement("CurrentStatus","hello world from php");
    $fieldsToUpdate->appendChild($statusElement);
                 
    $UPDATEOBJECTID="XXXXXXXXXXXXXXXXXX";
    $sObject = new SObject();
    $fieldsToUpdate = array ('CurrentStatus' => 'Hello world');
    $sObject->type = 'User';
    $sObject->Id = $UPDATEOBJECTID;
    $sObject->fields=$fieldsToUpdate;
    $response = $mySforceConnection->update(array ($sObject));
    print_r($response);

 

This is the message:  stdClass Object ( [errors] => stdClass Object ( [fields] => CurrentStatus [message] => User: bad field names on insert/update call: CurrentStatus [statusCode] => INVALID_FIELD_FOR_INSERT_UPDATE ) [id] => [success] => )

 

Do you have an idea ?

(It come from the sample in c#)

 

Thank you !

AkoAko

I'm getting the same thing.

No idea why that's considered an invalid field for update...

Anyone have an idea?

AkoAko

Just figured it out. I was using an old version of the partner WSDL file (pre-Chatter). Update it to the current one and it should work!

This was selected as the best answer
Kasu0Kasu0

It don't work for me , do you have an exemple ?

I have the same error for the moment