Z
Z
zayko2011-05-18 08:09:01
Facebook
zayko, 2011-05-18 08:09:01

What fields in the database should be provided for integration with the API of social services?

Greetings!
I'm making a multi-user system.
I form the structure of the table: profiles, where detailed data about the user will be stored.
I think in the future to make integration with social services so that some messages are automatically published on facebook, twitter. (contact, classmates, I would also like to screw my world one day).
As I understand it, a certain key will need to be obtained for the entire site - something like app-api-key - but I will store it in the project configuration file - I think there will be no problems with this.
But what about the keys of specific users? Do I need to store the password for access to the user's account in addition to the api-key?
Tell me, please, what fields should be provided in the database for storing keys / passwords for organizing interaction?

class CreateProfiles &lt; ActiveRecord::Migration<br/>
 def self.up<br/>
 create_table :profiles do |t|<br/>
 t.integer :user_id<br/>
 # messangers<br/>
 t.string :www, :limit =&gt; 100<br/>
 t.string :icq, :limit =&gt; 100<br/>
 t.string :skype, :limit =&gt; 100<br/>
 t.string :phone, :limit =&gt; 100<br/>
 t.string :address, :limit =&gt; 100<br/>
<br/>
# Social network fields<br/>
 t.string :facebook, :limit =&gt; 50<br/>
 t.string :twitter, :limit =&gt; 50<br/>
<br/>
# Social network API keys<br/>
 t.string :facebook_api_key, :limit =&gt; 150<br/>
 t.string :twitter_api_key, :limit =&gt; 150<br/>
<br/>
# Social network API passwords # НУЖНО ЛИ?<br/>
 t.string :facebook_password, :limit =&gt; 30<br/>
 t.string :twitter_password, :limit =&gt; 30<br/>
 end<br/>
end

Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Shaydurov, 2011-05-18
@GearHead

I understand you are writing on rails, so have a look at OmniAuth .
First, I would advise you to make the social media account model separate from the user profile. For example, if the user has two twitters.
Secondly, for the first time, if you are doing only authorization, you will only need t.string :adapter and t.string :s_id, where adapter is for example “facebook” or “twitter”, and sid is (it seems) an eight-byte number, however, which is better to store in a string if, for example, you later integrate not only through OAuth.
Further, you may need different fields for first name, last name, gender, age, for example. All social networks have different ones, and you need to look in the docks of each, which of them you need and which you don’t.
You don't need a password field. Authorization in the social. networks is now done through OAuth and token strings, so the maximum you need is the field under the token if you want offline access (i.e. do some actions with the user's account on the social network when he is not site). For more details, I advise you to look at the docks for OmniAuth.

Z
zayko, 2011-05-18
@zayko

First, I would advise you to make the social media account model separate from the user profile. For example, if the user has two twitters.
Good idea. I'll take note. However, this approach entails a lot of problems - how, for example, to choose which Twitter to post to? The problem also goes into the field of interfaces. And this is not pleasant for me. Still, I’ll probably leave one account in each network - guided by the principle of simplicity.

Z
zayko, 2011-05-18
@zayko

You don't need the password field... the maximum you need is the field under the token, well, that's fine.
I’ll leave only this for now, and if other needs come up, I’ll finish it as problems come up. Thanks for the detailed answer.
# Social network API keys
t.string :facebook_api_key, :limit => 150
t.string :twitter_api_key, :limit => 150

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question