मैं Google ऐप इंजन पर फेसबुक ग्राफ एपीआई का उपयोग कर रहा हूं। मैं उपयोगकर्ता से सभी मूलभूत जानकारी प्राप्त करने में सक्षम था। हालांकि जब मैंने किसी भी उपयोगकर्ता की जानकारी लाने की कोशिश की जिसके लिए अनुमति की आवश्यकता है, उदाहरण के लिए ईमेल करें, यह हमेशा किसी के रूप में दिखाई नहीं देता है। मैंने developers blog पर उपलब्ध संपूर्ण ट्यूटोरियल का पालन किया है।GAE पायथन में फेसबुक ग्राफ एपीआई का उपयोग करके मैं उपयोगकर्ता ईमेल कैसे प्राप्त करूं?
यहाँ मेरी कोड है:
class User(db.Model):
id = db.StringProperty(required=True)
created = db.DateTimeProperty(auto_now_add=True)
updated = db.DateTimeProperty(auto_now=True)
name = db.StringProperty(required=True)
email = db.StringProperty(required=True)
profile_url = db.StringProperty(required=True)
access_token = db.StringProperty(required=True)
class BaseHandler(webapp.RequestHandler):
"""Provides access to the active Facebook user in self.current_user
The property is lazy-loaded on first access, using the cookie saved
by the Facebook JavaScript SDK to determine the user ID of the active
user. See http://developers.facebook.com/docs/authentication/ for
more information.
"""
@property
def current_user(self):
if not hasattr(self, "_current_user"):
self._current_user = None
cookie = facebook.get_user_from_cookie(
self.request.cookies, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET)
if cookie:
# Store a local instance of the user data so we don't need
# a round-trip to Facebook on every request
user = User.get_by_key_name(cookie["uid"])
if not user:
graph = facebook.GraphAPI(cookie["access_token"])
profile = graph.get_object("me")
user = User(key_name=str(profile["id"]),
id=str(profile["id"]),
name=profile["name"],
email=profile["email"],
profile_url=profile["link"],
access_token=cookie["access_token"])
user.put()
elif user.access_token != cookie["access_token"]:
user.access_token = cookie["access_token"]
user.put()
self._current_user = user
return self._current_user
और यहाँ टेम्पलेट/HTML है:
<fb:login-button autologoutlink="true" perms="email"></fb:login-button>
{% if current_user %}
<p><a href="{{ current_user.profile_url }}"><img src="http://graph.facebook.com/{{ current_user.id }}/picture?type=square"/></a></p>
<p>Hello, {{ current_user.name|escape }}</p>
<p>email: {{ current_user.email }} </p>
{% endif %}
वहाँ कुछ गलत है? क्या उपयोगकर्ता ईमेल प्राप्त करने का कोई और तरीका है?
एफबी से प्राप्त प्रोफ़ाइल के कुछ डीबग आउटपुट जोड़ने का प्रयास करें और देखें कि ईमेल वहां है या नहीं। जब एफबी प्रमाणीकरण संवाद आता है, तो क्या इसमें ईमेल अनुमति शामिल है? – cope360