开发者

Facebook API registerUsers - Error 100: Invalid email hash

Using PyFacebook I am trying to register a test user of my site with my facebook application. I can connect to the API fine and return a list of friends etc. However when trying to register an address using:

hashed_emails = facebook.hash_email('foo@bar.com')
accounts = [hashed_emails]
facebook.connect.registerUsers(accounts)

I get:

FacebookError: Error 100: Invalid email hash specified whe开发者_StackOverflow中文版n trying to use connect.registerUsers(accounts)

Yet I know the hash is correct as the test hash in the documentation returns the same result:

mary@example.com = 4228600737_c96da02bba97aedfd26136e980ae3761

I also know the email address used is definitely a Facebook user. Moreover connect.getUnconnectedFriendsCount() works fine and returns the expected result (0!) - suggesting the link to the App is OK.

What's going on? Is connect.registerUsers() something that would only work once I've been given 'permission' to use Friend Linking? Or is the error message I'm receiving a catch all for a number of different results? Or have I just misunderstood the use of connect.registerUsers()?


Is the hash being stored as the right type?

Also, it may be good to store the hash as a separate variable in case there's some strange race condition popping up..


My request array to the API was incorrectly formatted. It should have been:

hashed_emails = facebook.hash_email('foo@bar.com')

# Wrong: accounts = [hashed_emails]
accounts = [{"email_hash": hashed_emails}] 

facebook.connect.registerUsers(accounts)

Which returned the expected response (list of registered hashes) and was further proven by connect.getUnconnectedFriendsCount() which now returns 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜