Jive software provide the facility to collaborate and communicate employees, customers and partners to work together. In this post we explain how to create a document in Jive software using jive rest api in PHP. So you automate the jive document creation process based on any trigger.
For this api call first you need to authenticate jive rest api and getting access token. Authentication process explain in my previous post How to Authenticate Jive Rest API Using Add On.
After jive authentication we can call create document api call.
Pass this document parameter in php curl code for creating a document.
1 2 3 4 5 6 7 8 9 10 11 |
$data1 = array( 'type' => 'document', // document type 'content' => array( 'type' => 'text/html', 'text' => 'Some interesting text', // document content here 'subject' => 'Harish Document' ); // Convert it into a json object $mydatse=json_encode($data1); |
Now using below php curl code to execute this jive api call. Pass access token in header as bearer type and use POST method with json object parameter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$headers = array( 'Authorization: Bearer Access Token', 'Content-Type: application/json' ); // Working Code sample for account information $ch12 = curl_init("https://sandbox.jiveon.com/api/core/v3/contents"); //open connection curl_setopt($ch12, CURLOPT_HTTPHEADER, $headers); //load all header data curl_setopt($ch12, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch12, CURLOPT_POSTFIELDS, $mydatse); curl_setopt($ch12, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch12); //execute post curl_close($ch12); $newdat = json_decode($result); echo "<pre>"; print_r($newdat); |
You can also follow the jive software documentation for detailed parameter and any other jive api mathod.
This document is created as an jive account author. You can also create a document as another jive author. For this you need Full Admin access with production account.
By default this feature is disable. You have to enable it by using the jive.api.run_as.strategies property in the Admin Console > System > Management > System Properties.
After this you can use X-Jive-Run-As [INSERT VALUE Email, Username and User id HERE] in header php curl code. This will create a document as other author in your jive software.