0
我目前使用PIMAX對於Facebook信使:https://github.com/pimax/fb-messenger-php從類訪問屬性 - PHP
我想從類UserProfile
訪問first_name
領域UserProfile.php
,並將其存儲在一個變量,這樣我可以使用名稱用於個性化消息給用戶。我很難做到這一點,而不會破壞機器人,並會感謝您的幫助!
這裏的UserProfile.php
文件:
<?php
namespace pimax;
class UserProfile
{
protected $data = [];
public function __construct($data)
{
$this->data = $data;
}
public function getFirstName()
{
return $this->data['first_name'];
}
public function getLastName()
{
return $this->data['last_name'];
}
public function getPicture()
{
return $this->data['profile_pic'];
}
}
預先感謝您的幫助!
你在哪裏創建這個類的一個實例:
您可以用提取的第一個名字嗎?防爆。 '$ up = new UserProfile($ data); $ up-> getFirstName();' 你當然需要自己提供$ data數組。 –