Ray*_*afa 3 php artificial-intelligence facebook-chatbot
嗨,我对PHP和Messenger Bots编码很新.
我想知道如何访问我的聊天机器人的名字.
该用户配置文件API可以帮助你.
使用event.sender.id从messenger bot服务器(/ webhook)收到的,并按照下面的请求
Run Code Online (Sandbox Code Playgroud)curl -X GET "https://graph.facebook.com/v2.6/<USER_ID>?fields=first_name,last_name,profile_pic,locale,timezone,gender&access_token=<PAGE_ACCESS_TOKEN>"
然后你可以得到下面返回的json
{
"first_name": "Peter",
"last_name": "Chang",
"profile_pic": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/p200x200/13055603_10105219398495383_8237637584159975445_n.jpg?oh=1d241d4b6d4dac50eaf9bb73288ea192&oe=57AF5C03&__gda__=1470213755_ab17c8c8e3a0a447fed3f272fa2179ce",
"locale": "en_US",
"timezone": -7,
"gender": "male"
}
Run Code Online (Sandbox Code Playgroud)