1

but i must make some script in php to populate our workplace from our database on a test workplace (so i have only 28day).

i have search for exemple to use the api cim from workplace. I search the web than 2 days but i don't find anything.

To test i just want to have the list of claimed user to understand how it goes with php.

I have try this :

<?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);
?>

the result give me "1" and the status give me 302.

can someone explain what is false, or where ican find a simple tutorial to start ?

Thank you

Thierry

4

1 回答 1

0

对不起这个问题,在搜索和混合答案后我发现:

使用 wordplace scim api 获取公司所有用户的 simpla 代码是:

<?php
$url = 'https://www.workplace.com/scim/v1/Users/';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER,
                array(
                    'Authorization: Bearer MyToken'
                    )
                
                );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1');

$result=curl_exec ($ch);

echo $result; 

curl_close ($ch);
?>

用户代理很重要。它在推荐行中工作。所以在cronjob中。知道我有创建会员的基础,并在电子邮件更改时更新会员。

谢谢

蒂埃里

于 2021-05-05T01:30:44.270 回答