Skip to content

Instantly share code, notes, and snippets.

@achinverma
Created July 4, 2021 06:12
Show Gist options
  • Save achinverma/c0dd82c943aa882390da7d9939271746 to your computer and use it in GitHub Desktop.
Save achinverma/c0dd82c943aa882390da7d9939271746 to your computer and use it in GitHub Desktop.
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