$value){ $$name = $value; } echo <<
Enter SugarCRM Portal User Information (to configure this login to SugarCRM as an admin and go the administration panel then select a user from user management)
PORTAL NAME:PORTAL PASSWORD:
Enter SugarCRM Portal Contact Information (to configure this login to SugarCRM as an admin and edit a contact. You will see Portal Information at the bottom of the Contact EditView Panel)
CONTACT NAME:
EOQ; if(!empty($portal_name)){ $portal_password = md5($portal_password); require_once('../include/nusoap/nusoap.php'); //must also have the nusoap code on the ClientSide. $soapclient = new nusoapclient('http://localhost/sugarcrm/soap.php'); //define the SOAP Client an //application_name is the client application connecting to sugar CRM for example mambo echo 'LOGIN:
'; $result = $soapclient->call('portal_login',array('portal_auth'=>array('user_name'=>$portal_name,'password'=>$portal_password, 'version'=>'.01'),'user_name'=>$user_name, 'application_name'=>'SoapTestPortal')); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

'; echo $soapclient->responseHeaders; echo '

HERE IS RESULT:
'; echo print_r($result); $session = $result['id']; echo '

GET CASES:
'; $result = $soapclient->call('portal_get_entry_list',array('session'=>$session , 'module_name'=>'Cases','where'=>"date_entered > '".date($GLOBALS['timedate']->dbDayFormat) ."'", 'order_by'=>'', 'select_fields'=>array('name', 'description', 'priority', 'status'))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $case_id = $result['entry_list'][0]['id']; echo '

GET Case fields:
'; $result = $soapclient->call('portal_get_module_fields',array('session'=>$session , 'module_name'=>'Cases')); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); echo '

CREATE Case:
'; $result = $soapclient->call('portal_set_entry',array('session'=>$session , 'module_name'=>'Cases', 'name_value_list'=>array(array('name'=>'name', 'value'=>'a case'), array('name'=>'description', 'value'=>'A case created through webservices')))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $case_id = $result['id']; echo '

CREATE Note:
'; $result = $soapclient->call('portal_set_entry',array('session'=>$session , 'module_name'=>'Notes', 'name_value_list'=>array(array('name'=>'name', 'value'=>'a note attached to a case'), array('name'=>'description', 'value'=>'A note created through webservices')))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $note_id = $result['id']; echo '

ATTACH A FILE:
'; $file = base64_encode('this would be the contents of your file'); $result = $soapclient->call('portal_set_note_attachment',array('session'=>$session, 'note_attachment'=>array('id'=>$note_id, 'filename'=>'an attached file', 'file'=>$file))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); echo '

ATTACH NOTE TO THE CASE:
'; $result = $soapclient->call('portal_relate_note_to_module',array('session'=>$session, 'note_id'=>$note_id, 'module_name'=>'Cases', 'module_id'=>$case_id)); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); echo '

GET NOTES RELATED TO A CASE:
'; $result = $soapclient->call('portal_get_related_notes',array('session'=>$session , 'module_name'=>'Cases', 'module_id'=>$case_id, 'select_fields'=>array('name', 'description', 'filename'))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $note_id = $result['entry_list'][0]['id']; echo '

GET ATTACHMENT TO A NOTE:
'; $result = $soapclient->call('portal_get_note_attachment',array('session'=>$session , 'id'=>$note_id)); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); echo '
It Reads:' . base64_decode($result['note_attachment']['file']); echo '

LOGOUT:
'; $result = $soapclient->call('portal_logout',array('session'=>$session)); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); echo 'LOG BACK IN:
'; $result = $soapclient->call('portal_login',array('portal_auth'=>array('user_name'=>$portal_name,'password'=>$portal_password, 'version'=>'.01'),'user_name'=>$user_name, 'application_name'=>'SoapTestPortal')); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $session = $result['id']; echo '

GET CASES:
'; $result = $soapclient->call('portal_get_entry_list',array('session'=>$session , 'module_name'=>'Cases','where'=>"date_entered > '".date($GLOBALS['timedate']->dbDayFormat) ."'", 'order_by'=>'', 'select_fields'=>array('name', 'description', 'priority', 'status'))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $case_id = $result['entry_list'][0]['id']; //FOR AUTHENTICATION YOU MUST DO A LOOK UP OF CASES BEFORE YOU TRY TO GET A NOTE RELATED TO A CASE echo '

GET NOTES RELATED TO A CASE:
'; $result = $soapclient->call('portal_get_related_notes',array('session'=>$session , 'module_name'=>'Cases', 'module_id'=>$case_id, 'select_fields'=>array('name', 'description', 'filename'))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $note_id = $result['entry_list'][0]['id']; echo '

GET ATTACHMENT TO A NOTE:
'; $result = $soapclient->call('portal_get_note_attachment',array('session'=>$session , 'id'=>$note_id)); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); //does not have accesss to this case $case_id = 'bf90ee6f-c7fa-520c-f4b4-4212a55eb969'; echo '

GET NOTES RELATED TO A CASE NOT RELATED TO THE LOGGED IN CONTACT:
'; $result = $soapclient->call('portal_get_related_notes',array('session'=>$session , 'module_name'=>'Cases', 'module_id'=>$case_id, 'select_fields'=>array('name', 'description'))); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); $note_id = $result['entry_list'][0]['id']; echo '

LOGOUT:
'; $result = $soapclient->call('portal_logout',array('session'=>$session)); echo 'HERE IS ERRORS:
'; echo $soapclient->error_str; echo '

HERE IS RESPONSE:
'; echo $soapclient->response; echo '

HERE IS RESULT:
'; echo print_r($result); } ?>