builder.php line 76 Object of class stdClass could not be converted to string
Closed this issue · 5 comments
Hello,
i find all deal in specific stage and i would like create activity but i receive an error :
Recoverable fatal error: Object of class stdClass could not be converted to string in .../vendor/devio/pipedrive/src/Builder.php on line 76
My code is
foreach ($EtapeRelanceSMS as $etape){
$rotten_days=$pipedrive->stages->find($etape)->getcontent()->data->rotten_days;
foreach ($pipedrive->deals->all(["stage_id" => $etape ,"status" => "open"])->getContent()->data as $thedeals){
$dateactivity = new datetime($thedeals->update_time);
$currentdate = new datetime();
if( $currentdate->diff($dateactivity)->format("%a") > $rotten_days ){
// create new activity
$pipedrive->activities->add(['type' => 'monsms', 'deal_id' => $thedeals->id, "person_id" => $thedeals->person_id, "note" => $contentSMSpart1 . $thedeals->value ." €". $contentSMSpart2 ,"user_id" => $thedeals->user_id]);
if ($EtapeRelanceSMS['relance'] == $etape){
//$pipedrive->deals->update($thedeals->id,["stage_id" => $EtapeRelanceSMS['attente']]);
}
if ($EtapeRelanceSMS['attente'] == $etape){
//$pipedrive->deals->update($thedeals->id,["status" => "lost"]);
}
if ($EtapeRelanceSMS['à suivre'] == $etape){
//$pipedrive->deals->update($thedeals->id,["status" => "lost"]);
}
echo $dateactivity->format("d/m/y"). " ".$currentdate->format("d/m/y") ." ";
echo ($currentdate->diff($dateactivity)->format("%a") . " ".$rotten_days ." ". $thedeals->id ." ". $thedeals->title ."<br>" );
}
};
}
The error is from
$pipedrive->activities->add(['type' => 'monsms', 'deal_id' => $thedeals->id, "person_id" => $thedeals->person_id, "note" => $contentSMSpart1 . $thedeals->value ." €". $contentSMSpart2 ,"user_id" => $thedeals->user_id]);
Best regards
This is the line that is causing the error, I do not see any object casting here, could you provide some more info?
https://github.com/IsraelOrtuno/pipedrive/blob/master/src/Builder.php#L76
in my code the line is just after "// create new activity". Every time i try with $pipedrive->activities->add( i receive an error
Recoverable fatal error: Object of class stdClass could not be converted to string in .../vendor/devio/pipedrive/src/Builder.php on line 76
Would you mind to paste a dump of the $options
variable just before the foreach loop? I mean in Builder.php
`<?php
/**
- User: nico
- Date: 22/01/2019
- Time: 16:45
*/
$EtapeRelanceSMS=["relance" => 51];
$contentSMSpart1 = "Bonjour, ";
$contentSMSpart2 =", intéressé ? Non tapez 0, Oui tapez 1. ";
require DIR . '/vendor/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
use Devio\Pipedrive\Pipedrive;
$dotenv = new Dotenv\Dotenv(DIR);
$dotenv->load();
$pipedriveurl = getenv('TWILIO_ACCOUNT_SID');
$pipedrive = new Pipedrive(getenv('PIPEDRIVE_TOKEN'));
foreach ($EtapeRelanceSMS as $etape){
$rotten_days=$pipedrive->stages->find($etape)->getcontent()->data->rotten_days;
foreach ($pipedrive->deals->all(["stage_id" => $etape ,"status" => "open"])->getContent()->data as $thedeals){
$dateactivity = new datetime($thedeals->update_time);
$currentdate = new datetime();
if( $currentdate->diff($dateactivity)->format("%a") > $rotten_days ){
$pipedrive->activities->add(['type' => 'sms_client', 'deal_id' => $thedeals->id, 'person_id' => $thedeals->person_id, 'note' => $contentSMSpart1 . $thedeals->value .' €'. $contentSMSpart2 ,'user_id' => $thedeals->user_id]);
// $pipedrive->activities->add(['type' => 'sms_client', 'deal_id' => $thedeals->id, 'person_id' => $thedeals->person_id, 'note' => $contentSMSpart1 . $thedeals->value .' €'. $contentSMSpart2 ,'user_id' => $thedeals->user_id]);
if ($EtapeRelanceSMS['relance'] == $etape){
//$pipedrive->deals->update($thedeals->id,["stage_id" => $EtapeRelanceSMS['attente']]);
}
if ($EtapeRelanceSMS['attente'] == $etape){
//$pipedrive->deals->update($thedeals->id,["status" => "lost"]);
}
if ($EtapeRelanceSMS['à suivre'] == $etape){
//$pipedrive->deals->update($thedeals->id,["status" => "lost"]);
}
echo $dateactivity->format("d/m/y"). " ".$currentdate->format("d/m/y") ." ";
echo ($currentdate->diff($dateactivity)->format("%a") . " ".$rotten_days ." ". $thedeals->id ." ". $thedeals->title ."<br>" );
}
};
}`
Hello ,
I found my error it's beacause with $pipedrive->deals->all(["stage_id" => $etape ,"status" => "open"])->getContent()->data , in the response, person_id is an stdClass Object :
[user_id] => stdClass Object
(
[id] => 371759
[name] => Philippe coi
[email] => info@test.com
[has_pic] =>
[pic_hash] =>
[active_flag] => 1
[value] => 371759
)
You can close the ticket .
Thanks a lot for your time