有没有人能帮我把这个写成httpRequest格式。我已经试过很多次了,都失败了。我不知道为什么,但我就是做不对。
curl -i --用户$YOUR_API_KEY_ID:$YOUR_API_KEY_SECRET \ 'https://api.stormpath.com/v1/tenants/current‘
任何帮助都将不胜感激。
发布于 2015-11-19 02:23:29
因此,要在PHP中获取当前租户,需要让curl跟随重定向,因为/tenant/current是到租户的302重定向,以获取您的API key。
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.stormpath.com/v1/tenants/current");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = array();
$headers[] = 'Authorization: Basic ' . base64_encode($YOUR_API_KEY_ID:$YOUR_API_KEY_SECRET);
$headers[] = "Accept: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);这样,它将返回您当前的租户资源。
可通过Composer安装,1.12.0版本处于稳定发布状态
https://stackoverflow.com/questions/33778230
复制相似问题