esround
esround
  • 发布:2023-10-13 16:54
  • 更新:2023-10-14 14:02
  • 阅读:359

uni-id-page params错误,好几天没弄上.

分类:uniCloud

uni-id-invalid-param为什么老提示这种信息呢,弄了两天还是没搞明白
php代码拿过来,域名化是用默认域名的。本地测试的。
RequestID ac1cd3721697186606212149135

我设置一样的params也不行呢。
整体代码发一下:


$requestAuthSecret = "testSecret"; //这个是已经在/uni-modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json里设置一样的$requestAuthSecret = "testSecret"并上传unicloud  
$nonce = sprintf("%d", rand());  
$timestamp = time() * 1000;  
$params = [  
        "externalUid"=>3,  
        "nickname"=>"aaaa"  
    ];  

$sign = new Sign($requestAuthSecret);  
$signature = $sign->getSignature($params, $nonce, $timestamp);  

$url = 'https://xxx.next.bspapp.com/uni-id-co/externalRegister';  

$timeout = 5;  
$data_type = "json";  
$post_data = array(  
    'clientInfo'=>array(  
        "uniPlatform"=>"app",  
        "appId"=>"__UNI__XXX"  
    ),  
    'params'=>array(  
        "externalUid" => 3,  
        "nickname" => "aaaa",  
    )  
);  
$header = [  
    "uni-id-nonce:".$nonce,   
    "uni-id-timestamp:".$timestamp,  
    "uni-id-signature:".$signature,  
    "Content-Type:application/json",   
    "Content-Control:no-cache"  
];  
$data= json_encode($post_data);  
$curl = curl_init();  

$curl = curl_init();      
        curl_setopt($curl, CURLOPT_URL, $url);      
        curl_setopt($curl, CURLOPT_POST, true); //发送一个常规的Post请求      
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);//Post提交的数据包      
        curl_setopt($curl, CURLOPT_HTTPHEADER, $header);      
        // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);      
        // curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);      
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);      

        $content = curl_exec($curl);      
        curl_close($curl);      
print_r($content);exit;

为什么为什么呢。。。

2023-10-13 16:54 负责人:无 分享
已邀请:
esround

esround (作者)

没法删除帖子呢,
已经解决了。

uid不能是数字,只能得字符串方式传递哈
$params = [
"externalUid"=>3,
"nickname"=>"aaaa"
];
改成
$params = [
"externalUid"=>"3",
"nickname"=>"aaaa"
];
希望别的朋友也参考哈

要回复问题请先登录注册