- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
所以我的客户需要一个使用 PHP 的 REST API,它根据 URL 参数的条件提供输出
现在基本上需要三个 URL,它们已经完成。
他们是
localhost/newapi/client/<AuthKey> - for authorizing
localhost/newapi/client/<clientid>/categories/ - to get all the categories
localhost/newapi/client/<clientid>/categories/<categoryid> - to get all items in a category
将 .htaccess 用于精美的 URL
所以现在他要求需要将 AuthKey 添加到 HTTP header 而不是 URL。所以 AuthKey 必须作为 header 传递,其余作为 URL 参数传递
所以我的问题是如何做到这一点。以及如何从请求中检索 AuthKey?
欢迎任何关于这个问题的教程或评论
最佳答案
您可以在客户请求您的 api 时告诉他添加如下 header :
AuthKey:你的-api-auth-key
或者
token :您的 API token
然后在你的 php 代码中做
$headers = getallheaders();
$token = $headers['Token'] or ['AuthKey'];
然后你检查数据库中的 key 然后处理你的代码
注意:
您的客户可以使用 PHP cURL 添加 header
curl_setopt($curl-handle, CURLOPT_HEADER, array(
'Token' => 'client-auth-token', //or
'AuthKey' => 'client-auth-token'
));
关于php - header 中的 AuthKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30432132/
所以我的客户需要一个使用 PHP 的 REST API,它根据 URL 参数的条件提供输出 现在基本上需要三个 URL,它们已经完成。 他们是 localhost/newapi/client/ - f
Google Docs 允许您仅使用 URL 共享文档。 URL 包含一个 key 和 authkey 来标识文档和授权访问。这允许匿名访问任何拥有 key 的人。 我想在应用程序中访问这种类型的共享
我已遵循有关如何设置 QuickBlox 提供的 iOS SDK 的所有指南。我通过 cocoa pod 添加了 SDK,添加了带有代码片段的运行脚本。示例 here !我来到十字路口,陷入了如何添加
我是一名优秀的程序员,十分优秀!