Marketo API Call and insert/update lead from third party using SOAP at CakePHP


1. First you need to download Marketo api php class file.You can download it from below link.
2. Download link: Download Marketo SOAP API PHP Client Class
3. Unzip the folder and put it to cakephp vendor folder
4. Now at CakePHP controller you can use this class to insert/update marketo lead

 


    function marketo_api_call($attributes) {
        $this->layout = 'null';
        $this->autoRender = FALSE;
        $email = $attributes['email'];

	//importing marketo class
        App::import('Vendor', 'marketosoapphpcient',
                   array('file' => 'marketosoapphpcient.php'));

	//Set default MKTOWS_USER_ID and  MKTOWS_SECRET_KEY
	define('MKTOWS_USER_ID', 'test_45454545454554D595850D6D12DHG38');
        define('MKTOWS_SECRET_KEY', '4545456456453132DDFDHGFGB704A9FC75');

        $accessKey = mktSampleMktowsClient::MKTOWS_USER_ID;
        $secretKey = mktSampleMktowsClient::MKTOWS_SECRET_KEY;
        $soapEndPoint = 'https://na-k.marketo.com/soap/mktows/1_7';
        $client = new mktSampleMktowsClient(
                    $accessKey, $secretKey, $soapEndPoint
        );
        $attrs = array(
            "City" => $attributes['city'],
            "Company" => $attributes['company_title'],
            "Country" => $attributes['country'],
            "Email" => $email,
            "FirstName" => $attributes['first_name'],
            "LastName" => $attributes['last_name'],
            "MobilePhone" => $attributes['cell_phone'],
            "Phone" => $attributes['work_phone'],
            "State" => $attributes['state'],
            "Title" => $attributes['job_title']
        );

	// syncLead called to perform insert/update lead 
        // to marketo list through Marketo API 
        $success = $client->syncLead($email, $attrs);
        return $success;
    }

 

Advertisements