Hello everyone, I use sdkbox facebook, to log in to the app, the process seems to be successful, but I need to know how I can capture the user’s email once the loguin is complete?
When you ask for permission it indicates that my app can access the email, name and photo
1 Like
i never try to get the email, you can try:
0x01 fetch friends info
sdkbox::FBAPIParam params;
params["fields"] = "id,name,email,first_name,installed,last_name,picture{url}";
PluginFacebook::api("me", "GET", params, "me_more");
FBAPIParam params;
params["fields"] = "id,email,name,installed,first_name,last_name,picture.type(small)";
api("me/friends", "GET", params,"__me_friends__");
0x02 deal with data
if (isLogin)
{
_loginItem->setString("Logout");
}
std::string title = "login ";
title.append((isLogin ? "success" : "failed"));
//MessageBox(error.c_str(), title.c_str());
}
void HelloWorld::onAPI(const std::string& tag, const std::string& jsonData)
{
CCLOG("##FB onAPI: tag -> %s, json -> %s", tag.c_str(), jsonData.c_str());
if (tag == "__fetch_picture_tag__") {
picojson::value v;
picojson::parse(v, jsonData);
std::string url = v.get("data").get("url").to_str();
CCLOG("picture's url = %s", url.data());
_iconSprite->updateWithUrl(url);
}
void HelloWorld::onAPI(const std::string& tag, const std::string& jsonData)
{
CCLOG("##FB onAPI: tag -> %s, json -> %s", tag.c_str(), jsonData.c_str());
if (tag == "__fetch_picture_tag__") {
picojson::value v;
picojson::parse(v, jsonData);
std::string url = v.get("data").get("url").to_str();
CCLOG("picture's url = %s", url.data());
_iconSprite->updateWithUrl(url);
}
else if (tag == "__me_friends__") {
// code here;
}
}
Thanks,
Good morning, thanks for the information, sorry for the ignorance, but how can I apply that code to cocos creator and javascript?
did you try to find the javascript example ?
// var params = new Object();
// params.fields = "id,name";
// sdkbox.PluginFacebook.api("/me/friendlists", "GET", params, "/me/friendlists");
1 Like
system
closed
December 19, 2019, 8:39pm
#5
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
Good afternoon,
With the example of the shared link, it worked correctly.
// var params = new Object();
// params.fields = "id,name";
// sdkbox.PluginFacebook.api("/me/friendlists", "GET", params, "/me/friendlists");
Thank you very much