progrez.cloud

Source Code Update Data ke Task Progrez Cloud

10 Agustus 2020

function.php


<?php


function ch
(
	$url,
	$post
)
{


	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


	$data = curl_exec($ch);
	curl_close($ch);


	return $data ;
}


function deBug(
	$ini_url,
	$token
)
{
	$url 	= $ini_url;
	$post 	= "token=" . $token . "&getTasks=1";


	$data = ch($url, $post);


	return $data ;
}
function postData(
	$url,
	$ini_token,
	$key,
	$parent_id,
	$task_id,
	$task_name,
	$description
)
{
	$post_field = [
		'token' 		=> $ini_token,
		'user_key' 		=> $key,
		'task'			=> [
			'parent_id'		=> $parent_id,
			'task_id'		=> $task_id,
			'task_name'		=> $task_name,
			'description'	=> $description,
			'privacy'		=> '2',
			'filenya'		=> '',
			'tasktype'		=> '1',
			'nominal'		=> '0',
			'quantity'		=> 0,
			'io'			=> 1,
			'sticky'		=> '0' //0 = defaul, 1 = pinned
		]
	];




	foreach ($post_field as $k => $v){
		if ( is_array($v)){
			foreach ( $v as $kk => $vv){
				$data_x[$k][$kk] = $k . '[' . $kk . ']=' . $vv ;
			}
			$data_y[] = implode('&', $data_x[$k]);
		}else {
			$data_x[$k] = $k . '=' . $v;
			$data_y[] = implode('&', $data_x);
		}
		$post = implode('&', $data_y);
	}


	$data = ch($url, $post);


	return $data ;
}


update_task.php

<?php
include 'function.php';


$url = 'https://progrez.cloud/services/project';
$token = 'TOKEN_PROJECT'; //ubah ini


// print_r(deBug(
// 	$url,
// 	$token
// ));

$url = 'https://progrez.cloud/sa/task/update';
$user_key = 'YOUR_USER_KEY'; `//ubah ini
$parent_id = 'parent_id'; //ubah ini
  $task_id = 'task_id'; //ubah ini
  $nama_task_baru = 'Nice :)';
  $description = '';
  
  
  print_r(postData(
  	$url,
  	$token,
  	$user_key,
  	$parent_id,
  	$task_id,
  	$nama_task_baru,
  	$description
  ));