【发布时间】:2021-07-27 03:30:31
【问题描述】:
但我必须在 php 中编写一些脚本,以便在测试工作场所的数据库中填充我们的工作场所(所以我只有 28 天)。
我已经搜索了使用工作场所的 api cim 的示例。 我在网上搜索了超过 2 天,但我什么也没找到。
为了测试,我只想拥有声明用户的列表,以了解它与 php 的关系。
我试过这个:
<?php
$url = 'https://www.workplace.com/scim/v1/Users';
$json = '{"urn:scim:schemas:extension:facebook:accountstatusdetails:1.0" :{ "claimed": true}}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array('Content-Type: application/json',
'Content-Length: ' . strlen($json),
'Authorization: Bearer mytoken'
)
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result=curl_exec ($ch);
echo $result;
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "status :".$status_code."<br>"; //get status code
curl_close ($ch);
?>
结果给我“1”,状态给我 302。
有人可以解释什么是错误的,或者我可以在哪里找到一个简单的教程来开始?
谢谢
蒂埃里
【问题讨论】:
-
您是否尝试过使用
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);获取内容? -
我刚试过,现在没有1了,结果什么都没有。