Closed SoulArcangel77 closed 7 years ago
probable solution in UserProfile.php
namespace pimax;
class UserProfile
{
protected $data = [];
public function __construct($data)
{
$this->data = $data;
}
public function getFirstName()
{
return isset($this->data['first_name']) ? $this->data['first_name'] : null;
}
public function getLastName()
{
return isset($this->data['last_name']) ? $this->data['last_name'] : null;
}
public function getPicture()
{
return isset($this->data['profile_pic']) ? $this->data['profile_pic'] : null;
}
public function getLocale()
{
return isset($this->data['locale']) ? $this->data['locale'] : null;
}
public function getTimezone()
{
return isset($this->data['timezone']) ? $this->data['timezone'] : null;
}
public function getGender()
{
return isset($this->data['gender']) ? $this->data['gender'] : null;
}
}
Can you give an example?
For me, the following code works
$user = $bot->userProfile('FACEBOOK_USER_ID');
echo $user->getFirstName() ." ". $user->getLastName();
The following function call is not possible:
FbBotApp::userProfile($messenger_id)
I have created a script that send a newsletter to all my contac who use messenger, so now i have 800 messenger_id of which approximately 100 users not have setted the first_name. When userProfile not find the first_name, the script stops with error!
I have solved using isset in UserProfile.php
Ok, thanks. I will fix it. Maybe an empty string is better than null
For those who use the function is_null(), is better null, for those who use the function empty() is indifferent :)
So, we use null
Hi, when i use the function FbBotApp::userProfile($messenger_id) my script stops with the error:
[ErrorException]
Undefined index: first_name
How do i use FbBotApp::userProfile witouth stop my script?