Saving facebook id as int or varchar?

后端 未结 7 2017
小鲜肉
小鲜肉 2020-12-29 02:32

My question is more advisory than technical. I\'m writing a Facebook app in which I am fetching some information about the user, including facebook_id.
I was wondering i

相关标签:
7条回答
  • 2020-12-29 02:43

    For new data types, as they are grahp obj ID, I believe it is safe to save them as BINT. However, for old "id", e.g. pic, save them as string (you can easily see that they are in the format xxxxxx_xxxxxxxx)

    0 讨论(0)
  • 2020-12-29 02:44

    Although unlikely, facebook could change the format of their ID's, so to make it future proof, I'd use a varchar.

    0 讨论(0)
  • 2020-12-29 02:47

    similar question to: Facebook user_id : big_int, int or string?

    "I would not use a string. That makes comparisons painful and your indexes clunkier than they need to be."

    0 讨论(0)
  • 2020-12-29 02:48

    Use BIGINT(64) to store Facebook User IDs.
    Here you go: https://developers.facebook.com/blog/post/45/

    0 讨论(0)
  • 2020-12-29 03:00

    Facebook uses 64-bit integers (bigint) for their user ids. So you use Bigint UNSIGNED in MySQL.

    "As a reminder, in the very near future, we will be rolling out 64 bit user IDs. We encourage you to test your applications by going to www.facebook.com/r.php?force_64bit and create test accounts with 64 bit UIDs."

    Edit: Facebook usernames is not the same thing as the user id. The username is of course varchar but will not be returned as the id.

    0 讨论(0)
  • 2020-12-29 03:01

    To quote facebook's upgrade notes regarding graph API v2.0 (effective May 2015):

    All IDs are strings. In v1.0, IDs were often large numbers.

    Which (to me) implies that userids are not guaranteed to be numbers. In fact, facebook recommend that you use strings:

    https://developers.facebook.com/docs/graph-api/reference/v2.2/user#fields

    Name:id
    Description: id The id of this person's user account.

    This ID is unique to each app and cannot be used across different apps(...)

    type: string

    Although I must admit I've never seen an alphanumeric id.

    0 讨论(0)
提交回复
热议问题