Created
July 4, 2021 06:12
-
-
Save achinverma/c0dd82c943aa882390da7d9939271746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Future<FacebookModel> getFbUserData(String fbtoken) async { | |
//String url1 = "https://graph.facebook.com/${user_id}?fields=name,first_name,last_name,email,&access_token=${fbtoken}"; | |
String url = | |
'https://graph.facebook.com/v8.0/me?fields=name,first_name,last_name,email&access_token=${fbtoken}'; | |
var request = new http.MultipartRequest("GET", Uri.parse(url)); | |
try { | |
final response = await request.send().timeout(Duration(seconds: timeout)); | |
final respStr = await response.stream.bytesToString(); | |
print("----url---${url}"); | |
print("----respStr---${respStr}"); | |
final parsed = json.decode(respStr); | |
FacebookModel fbModel = FacebookModel.fromJson(parsed); | |
return fbModel; | |
} catch (e) { | |
print("----catch---${e.toString()}"); | |
//Utils.showToast(e.toString(), true); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment