问题标签 [codeigniter-restserver]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - Codeigniter 3 + Restserver 总是执行获取请求
我正在使用Codeigniter 3.1.0,从这里下载的Restserver 以及从这里的文档。我也在使用 Chrome 的扩展Postman。
问题是,即使我从 Postman 的下拉菜单中选择 POST,它也会命中 get 方法......下面是代码:
现在通过 Postman,如果我选择GET到 URL example-domain.com/api/example/users预览是获取请求
如果我选择POST到相同的 URL example-domain.com/api/example/users预览再次获取请求而不是发布请求
我没有更改config/rest.php中的任何内容,我正在使用控制器/api/example中已实现的 Restserver 示例
有谁知道为什么我不能点击 POST 方法?
codeigniter - REST 用户注册和通过 Api Key 登录
我对 codeignitor 并不陌生,但我仍然没有使用它们称为“API 密钥”身份验证的功能。
我想做的事 ?
my_users
在表中注册一个用户,并且在用户注册时有一个apikey
列应该存储和生成唯一的 api。- 登录用户,用户提供用户名,密码,如果提供正确的信息,它会得到登录的响应,并
apikey
在my_users
表中分别列出。 - 登录后,我想将 apikey 用于所有其他与用户相关的调用
bookATask
,例如 header asX-API-KEY
,这将允许我在客户端控制用户会话并保护登录和签名系统。
设置中的问题:
- 每次我发出传递请求时都会被问到
X-API-KEY
这是错误的,因为控制器中可能存在注册用户的调用register_post
,User
并且 Api 密钥不能在标头中传递,除非它是在此方法中生成的,对吗? - 我只是得到 status:FALSE 和 error:
Invalid Api key
在我拨打的每个电话上。
我在做什么?
(仅更改代码)
应用程序/配置/rest.php
应用程序/配置/autoload.php
控制器/api/Key.php
(控制器中用于生成 Api 密钥的方法)
在数据库上,我有两个额外的表app_limits
,app_logs
和表中apikey
带有 varchar(40) 的my_users
列,任何人都可以帮我解决我的问题,我做错了什么?
json - codeigniter-restserver 如何将 json 放入响应中
我正在尝试将 json 数据放入 codeigniter-restserver 响应中,但是 json 代码被放入双引号中,有效地使其不可读。我目前正在尝试设置这样的响应:
$result['result']
json代码在哪里。
codeigniter - Codeigniter Restserver 基本认证始终有效
我对 Codeigniter Restserver ( https://github.com/chriskacerguis/codeigniter-restserver ) 有疑问,因为我启用了基本身份验证,但即使凭据错误,它也会始终返回结果。请参阅下面的详细信息:
在 rest.php 文件中我修改了值: $config['rest_auth'] = ''; 到 $config['rest_auth'] = 'basic';
然后
$config['auth_source'] = 'ldap'; 到 $config['auth_source'] = '';
凭证存储在$config['rest_valid_logins'] = ['admin' => '1234'];
但是,如果我尝试调用我的网络服务,即使凭据错误或遗漏,它也会给出结果。为什么?
谢谢。
php - codeigniter REST 服务器库中基于令牌的身份验证
我正在尝试codeigniter
使用 Phil Sturgeon 的休息服务器构建休息 API
问题是我不知道如何进行基于令牌的身份验证。我正在为移动应用程序构建该 API,它是通过 HTTPS 实现的。首先,用户将通过登录进行身份验证,然后他将能够使用应用程序功能。我想以这里解释的方式实现:How to token-based authentication works
问题:
如果我在请求中将令牌发送到服务器,我应该在哪里检查有效性?
休息服务器库是否支持基于令牌的身份验证?
如果可以,我需要做哪些配置?或者我需要实现我的身份验证方法?
还是有更好/更简单的身份验证方式而不是基于令牌的方式?
php - Codeigniter 不允许通过 url 在 REST API 发布方法中发布数据。它显示未知方法之类的错误
我正在尝试通过 url 发送数据,例如
http://localhost/api/index.php/society/?date=20/04/2017&s_name=ssr
但它显示错误消息:
{“状态”:假,“错误”:“未知方法”}
当我使用postman
或advance rest client
应用程序进行测试时,它工作正常,数据正在发布和更新数据库。
网址:http://localhost/api/index.php/society
我的控制器……
我的模特……
codeigniter - 预检响应中的 Access-Control-Allow-Headers 不允许 Angular 2 请求标头字段授权
我正在为我的服务器应用程序使用 codeigniter REST API。客户端作为 Angular2,在我的 REST API 中我已经给出了基本的身份验证。我已经设置为
和
而且对于CORS Check,我使用了以下代码,
而且我还尝试在我的休息控制器中明确尝试过,
我在角度使用了下面的代码,
当我与邮递员核对时,它运行良好,没有任何问题。当检查角度误差时,
如果我将其余身份验证设为错误并删除授权标头,则无需检查 api 用户名和密码即可正常工作
并在角度
请帮助任何人为我的 api 应用身份验证。
php - 如何在codeigniter中显示特定字段的表单验证消息
在这里,我想显示不同字段的验证消息
如果我提供密码并将电子邮件字段留空,则两条消息都显示在 rest api 中
谁能帮我
mysql - New session entries are being created in database even when codeigniter session library is not loaded. Why?
I am having a rather weird problem with Chris Kacerguis’ CodeIgniter REST Server.
Problems:
1) I am NOT loading the CodeIgniter session library, even then new entries are being created in the ci_sessions
database table, everytime I am making an HTTP Request to my REST Api.
2) A brand new entry is being created (and the old entry is NOT being updated) in the db, on every HTTP Request, even when the IP Address is remaining the same.
This is my config.php file:
I tried, individually and in combination, the following things:
and
But nothing worked.
Is this normal or some kind of a bug? What am I doing wrong? Anyone else having the same problem?
Another thing is that, I am not facing this issue in vanilla CodeIgniter. There, everything is working fine and as expected.
Update
I found something while struggling with the second part of the problem.
Two session entries are being created in the database while making the first HTTP Request - one for the client and another one for the REST Server. From the second request, the client 'version' of the cookie is being UPDATED while the server 'version' is being RE-GENERATED.
php - Codeigniter Restserver - 通过 API 调用每个函数时的最佳实践
我正在将 Codeigniter restserver 用于社交网络项目。我想通过 API 访问我的所有网站功能(即登录、getfriends、postcomments、uploadimages 等)。现在我有一个问题,我应该在 API 上添加任何类型的身份验证(rest_auth、密钥等)还是应该保持开放?API应该如何设计?
我相信通过在配置中使用restserver自己的身份验证设置,每个函数调用都需要身份验证,但就我而言,我不需要对登录或注册功能进行身份验证。
我可以在函数中使用自己的会话检查吗?还是有更好的方法,因为我相信 restserver 肯定会有我在这里缺少的东西。