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
EVENTAPI EVENTAPIEVENTAPI EVENTAPI 

How create Accounts from php sdk ?

Hello
I want create Accounts from php sdk ...
In create contacts, need fill "Account Name" fields .
if Account exists, i has account ids and correct fill AccountId field,
But sometime, need create new Account for contacts , how i do it ? 
thanks !
Ankit Gupta@ DeveloperAnkit Gupta@ Developer
Hi EventAPI,

Please go through the Salesforce REST API document. 
You can login into salesforce by using Oauth protocol and after that you can perform all teh actions from php whatever you want.

For more detail pelase follow below link:
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/

 
EVENTAPI EVENTAPIEVENTAPI EVENTAPI
I want to create accounts with the backend, without external oauth.
For example, when selling products on my website, I need to create an account with the name of the product category, and in it define the contact.
Posible this is done only with the help of PHP SDK ?
EVENTAPI EVENTAPIEVENTAPI EVENTAPI
ok. Account created ! 
private function create_account($name = 'TEST Company') {
        $sObject = new \stdclass();
        $sObject->name = trim($name);
        $accountId = null;
        $createResponse = $this->mySforceConnection->create(array($sObject), 'Account');
        if(isset($createResponse[0]->id) && $createResponse[0]->id) {
            $accountId = $createResponse[0]->id;
        }
        return $accountId;
    }

next questions .... How create  Campaign ?

i try create Campaign
$sObject = new \stdclass();
        $sObject->Name = trim("TEST Campaign");      
        $sObject->Description = "TEST Campaign";     
        $createResponse = $this->mySforceConnection->create(array($sObject), 'Campaign');

        print_r($createResponse);

getting errors :
Array
(
    [0] => stdClass Object
        (
            [errors] => Array
                (
                    [0] => stdClass Object
                        (
                            [message] => entity type cannot be inserted: Campaign
                            [statusCode] => CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
                        )

                )

            [id] => 
            [success] => 
        )

)

what I am doing wrong?
EVENTAPI EVENTAPIEVENTAPI EVENTAPI
ok. i foget turn on "marketing user" in access settings 
EVENTAPI EVENTAPIEVENTAPI EVENTAPI
How attach Contact to Campaign ? =)