简体   繁体   English

如何创建PHP REST API客户端以使用户登录到服务器?

[英]how to create a PHP REST API Client to get the user logged in on the server?

i want to create a php web app with REST API.where user logins on the Server/Main site. 我想使用REST API创建一个php Web应用程序。用户在服务器/主站点上登录。 problem is that how to get current logged in user on a php client.i am using CURL at client to get data from server. 问题是如何获取当前在php client上登录的用户。我正在客户端使用CURL从服务器获取数据。 if i store a user cookie in browser when user logins on my site, then client can't access them because CURL doesn't send cookies when requesting. 如果我在用户登录我的网站时在浏览器中存储用户cookie,则客户端无法访问它们,因为CURL在请求时不会发送cookie。 if i use CURL COOKIEJAR or COOKIEFILE, they will not safe since a client can store cookies data and use them for access user's account. 如果我使用CURL COOKIEJAR或COOKIEFILE,它们将不安全,因为客户端可以存储cookie数据并将其用于访问用户帐户。 i want my API to be like Facebook API. 我希望我的API像Facebook API。 how FB API knows who is currently logged in? FB API如何知道谁当前登录? i only want to know is there any way to get the currently logged in user on server site.either by cookie or by session. 我只想知道有什么方法可以通过cookie或会话来获取服务器站点上当前登录的用户。 please someone help me thanks 请有人帮我谢谢

Facebook API and Twitter API uses Oauth http://oauth.net/ Facebook API和Twitter API使用Oauth http://oauth.net/

Oauth is awesome for the man in the middle login. 对于中间登录的人,Oauth很棒。 Oauth connect the user with the final server and to the server in the middle it gives a token, that token is the way to know who is logged. Oauth将用户与最终​​服务器连接,并在中间服务器提供一个令牌,该令牌是知道记录谁的方式。

https://developers.facebook.com/docs/reference/dialogs/oauth/ https://developers.facebook.com/docs/reference/dialogs/oauth/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM