SOAP-ERROR: When using Enterprise Client for SalesForce - php

I am attempting to pass a custom field via a SOAP Client to SalesForce, here's my existing code:
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
$leadConvert = new stdClass;
$leadConvert->leadId = $eLEADID;
$leadConvert->Custome_field = true;
$leadConvertArray = array($leadConvert);
echo "<pre>";
print_r($leadConvertArray);
echo "</pre>";
$leadConvertResponse = $mySforceConnection->convertLead($leadConvertArray);
echo "<pre>";
print_r($leadConvertResponse);
echo "</pre>";
}
catch (Exception $e) {
echo $e->faultstring;
}
The way it's being passed to SOAP is this:
Array
(
[0] => stdClass Object
(
[leadId] => XXXXXXXXXX
[Custom_field] => 1
)
)
And my error that I am getting is as follows:
SOAP-ERROR: Encoding: object has no 'convertedStatus' property
Do I have to set something in the WSDL in order for this to work? This is to attempt to update a leadID in SalesForce to have it be converted to account/opportunity.
Is there a better way for me to debug this and see what I am missing maybe from the WSDL?
Note: the error means that you "literally" don't have the parameter set in the request. To fix it, simply pass what it's complaining about.
New Issue:
After adding the request, I am getting the following error:
Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location
Not quite sure what that error means at all. Any thoughts?

For the error:
Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location
It appears you are trying to set a custom field on the Lead record to a boolean value.
Custom fields in Salesforce will typically end with the __c suffix.
Check the API name for the field in Salesforce and ensure the user who generated and is accessing the Enterprise API has field level access to it.
Then you code should be something like:
$leadConvert->Custom_field__c = true;
It also seems a bit odd that you are setting a custom field for a Lead and then passing it to the convertLead() web method. See the LeadConvert Arguments, which include convertedStatus.

Related

Google Api PHP unable to pass variable to call('list')

I am trying to run the following code with the new Google Business Profile API:
$mybusinessbusinessinformationService = new Google\Service\MyBusinessBusinessInformation($client);
try
{
$locations = $mybusinessbusinessinformationService->accounts_locations->call('list',['parent'=>'accounts/1111111111111111111']);
var_dump($locations);
} catch(Exception $e){
var_dump(print_r($e->getMessage(),1));
}
But I am getting the following error:
(list) missing required param: 'parent'
As far as I can tell it seems that I am parsing the param properly.
For people that are searching for an answer:
Since Google updated its API, it's a requirement to parse readMask as well:
$mybusinessbusinessinformationService = new Google\Service\MyBusinessBusinessInformation($client);
$params = array('readMask'=> "title,name");
$locations = $mybusinessbusinessinformationService->accounts_locations->listAccountsLocations($getAccountName,$params);
var_dump($locations);
You can find the mask parameters here:
https://developers.google.com/my-business/reference/businessinformation/rest/v1/locations

Docusign API PHP TemplatesApi::updateDocument FORMAT_CONVERSION_ERROR

I'm trying to update a template document via PHP API using this: https://github.com/docusign/docusign-php-client/blob/master/src/Api/TemplatesApi.php#L4946
I get one of two errors depending on if I set the apply_document_fields option.
Without it set, I get UNSPECIFIED ERROR Value cannot be null.\r\nParameter name: fileBytes. However, if I view the request body before sending, document_base_64 is set as expected.
With apply_document_fields set 'true' (actual boolean value is not supported), I get FORMAT_CONVERSION_ERROR The data could not be converted.
Either way, it seems like the document data is not getting sent correctly, but I can't figure out how I'm supposed to be sending it. Here's my code:
public static function updateTemplateWithDocument(string $documentId, string $templateId, $documentBody = null)
{
$api = My_Service_Docusign::getInstance();
$templatesApi = new DocuSign\eSign\Api\TemplatesApi($api->getAuth());
$document = new \DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode($documentBody));
// Got an error reusing $documentId, so I'm incrementing it now
$document->setDocumentId((string) (((int)$documentId) + 1));
$def = new DocuSign\eSign\Model\EnvelopeDefinition();
$def->setDocuments(array($document));
$opts = new \DocuSign\eSign\Api\TemplatesApi\UpdateDocumentOptions();
// Different behavior with this set vs not
$opts->setApplyDocumentFields('true');
$res = $tmpApi->updateDocument($api->getAccountId(), $documentId, $templateId, $def, $opts);
return $res;
}
Unfortunately, DocuSign support doesn't support their API :-(
I figured out I need to use TemplatesApi::updateDocuments (plural) instead, which also allows me to reuse the documentId.

PHP - Access twitter api response variables

I'm using the twitter api to get my latest mentions.
Twitter api link: https://dev.twitter.com/rest/reference/get/statuses/mentions_timeline
Function used to get last mentions:
function twitter_get_tweets(){
$connection = $this->twitter_auth();
$latest_tweet = $connection->get('statuses/mentions_timeline', array('count' => 1));
return $latest_tweet;
}
Preview of response: http://projects.helpful.ninja/twitter/
Sadly im not able to access the variables in there directly, such as the text node.
Example:
[text] => #pr0b_ Submit a request to our Support team and they'll be in touch ASAP
Been testing something like:
$twitter_bot = new twitter_bot_functions($twitter_settings['api_key'], $twitter_settings['api_secret'], $twitter_settings['access_token'], $twitter_settings['access_token_secret']);
$get_latest_mention = $twitter_bot->twitter_get_tweets();
echo $get_latest_mention['text'];
Does someone have a idea what I'm doing wrong?
It is an array first and then a stdClass object. So you should use it like
echo $get_latest_mention[0]->text;

LastInsertId with Parse Database

I'm new in Parse and I come from mysql. In mysql, it's possible to get the last id inserted in the database width $db->lastInsertId(). I don't find how to do it with Parse db, can you help me please ?
How to get the last insert id in a Parse Database ?
Thank you
With the Parse PHP SDK, everything is Object-based. This means when you create and save the Parse object in your Parse storage, you can use the getObjectId() method of the ParseObject to retrieve the object ID after saving:
$gameScore = new ParseObject("GameScore");
$gameScore->set("score", 1337);
$gameScore->set("playerName", "Sean Plott");
$gameScore->set("cheatMode", false);
try {
$gameScore->save();
echo 'New object created with objectId: ' . $gameScore->getObjectId();
} catch (ParseException $ex) {
// Execute any logic that should take place if the save fails.
// error is a ParseException object with an error code and message.
echo 'Failed to create new object, with error message: ' + $ex->getMessage();
}
From the above example, the notable method we've used is $gameScore->getObjectId(). The respective output would be:
New object created with objectId: xWMyZ4YEGZ
This is different from the lastInsertId() method because the value obtained from getObjectId() will always be the same for a particular object after it has been saved to the Parse cloud.

Why php's soapCall gives string conversion error?

// Set username and password
$ih_soap_user= $this->config->item('interUser');
$ih_soap_pass=$this->config->item('interPass');
//echo $ih_soap_user.':P:'.$ih_soap_pass;
// Set soap namespace
$ih_soap_ns = 'http://www.interhome.com/webservice';
// Create new instance of SoapClient with the interhome web service URL
$client = new
SoapClient($this->config->item('interSoap'),array('trace'=>'1'));
// Create new soap header and set username and password
$header = new SoapHeader($ih_soap_ns,
'ServiceAuthHeader',
array('Username' => $ih_soap_user,'Password' =>
$ih_soap_pass),
true
);
// Prepare p// Prepare parameters
$params = array('inputValue' =>array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>array('House'=>'House'),
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'',
) );
try{
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
Hi guys..Any Idea why this call when I pass any not empty array, as for example ,as I made for 'HouseApartmentType', returns this error
A PHP Error was encountered
Severity: Notice Message:
Array to string conversion
Filename:
controllers/houses.php Line
Number: 269
And when it's only empty array or a string the soap call function is working... I need to pass array of options to one parameter....
LINE 269 is
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
This is probably solved already, but I also had problems with this and I thought I should post here when I finally found the solution. (The solution is not nusoap, it throws the same error.)
The error only seems to come from the soapCall call generation, it really is the Web Service that causes it. When you run __soapCall, it first asks the server which datatypes the parameters should have and then tries to comply. So if you try to feed an array when the service expects a string, it will do the array to string conversion when the request is generated.
i think you should look at the manual how a soapcall work:
$params = array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>'House', // changed to string instead of array
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'' );
i simplified the array and you should test it and look if this is the kind of result you are looking for.
Also look for ordering errors like the example shown in php.net

Categories