我们希望通过WEB-Java应用程序创建Quickblox用户。
为了实现相同的工作,我们首先尝试通过Postman和CURL进行REST API调用,然后继续使用Java代码。
但是,我们收到500内部错误
URL
https://api.quickblox.com/session.json
Header
Content-Type: application/json"
QuickBlox-REST-API-Version: 0.1.0
体
{"application_id": “35221”, "auth_key": "wU8JrJ-DKamUB8v", "timestamp": “1456378718”, "nonce": “1112”, "signature": "81f3967265c87de025010eb9298d169555085e91”}
生成签名
application_id=35221&auth_key=wU8JrJ-DKamUB8v&nonce=1112×tamp=1456378718
以下是我们得到的回应`Connection→keep-alive
Content-Length → 948
Content-Type → text/html; charset=utf-8
Date → Thu, 25 Feb 2016 05:48:08 GMT
Server → nginx/1.8.0
Status → 500 Internal Server Error
X-Rack-Cache → invalidate, pass
X-Request-Id → 3a47c3daaf9ad353a5b592459c6f3345
X-Runtime → 0.003346`
至于我的理解,参数是在API文档中建议的。请帮忙,因为我们有点卡住它,无法前进。
同时发布导致相同错误的卷曲等效项
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0” \
-d '{"application_id": “35221”, "auth_key": "wU8JrJ-DKamUB8v", "timestamp": “1456378718”, "nonce": “1112”, "signature": "81f3967265c87de025010eb9298d169555085e91”}’ \
https://api.quickblox.com/session.json
application_id=35221&auth_key=wU8JrJ-DKamUB8v&nonce=1112×tamp=1456378718
authorisation secret - FEu2AN8CfgU7VF4
感谢, aakash
答案 0 :(得分:0)
首先定义与应用程序相关的所有内容:
DEFINE('APPLICATION_ID', 23424);
DEFINE('AUTH_KEY', "dfsadfasdfsadf-");
DEFINE('AUTH_SECRET', "23421342134");
DEFINE('USER_LOGIN', "rahul");
DEFINE('USER_PASSWORD', "fghdf56456456");
// Quickblox endpoints
DEFINE('QB_API_ENDPOINT', "https://api.quickblox.com");
DEFINE('QB_PATH_SESSION', "session.json");
定义后,创建签名并在curl session api hit中传递$post_body
,获取令牌并在所有webservices php
中使用令牌:
$nonce = rand();
$timestamp = time();
$signature_string = "application_id=".APPLICATION_ID."&auth_key=".AUTH_KEY."&nonce=".$nonce."×tamp=".$timestamp."&user[login]=".USER_LOGIN."&user[password]=".USER_PASSWORD;
$signature = hash_hmac('sha1', $signature_string , AUTH_SECRET);
$post_body = http_build_query(array(
'application_id' => APPLICATION_ID,
'auth_key' => AUTH_KEY,
'timestamp' => $timestamp,
'nonce' => $nonce,
'signature' => $signature,
'user[login]' => USER_LOGIN,
'user[password]' => USER_PASSWORD
));