API Workplace Account Manager in php

141 views Asked by At

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

1

There are 1 answers

0
troussel On

Sorry for this question, after search and mixt answer i have found:

The simpla code with wordplace scim api to get all user ofthe company is :

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

The user agent is important. it work in commendline. so in cronjob to. Know i have my basis to create member, and to update member when emails are changing.

Thank's

Thierry