-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsync.php
More file actions
59 lines (43 loc) · 2.06 KB
/
sync.php
File metadata and controls
59 lines (43 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
include('config.php');
echo $cid = $_POST['cid'];
echo $z_key = $_POST['z_key'];
#https://crm.zoho.com/crm/private/xml/Events/getSearchRecords?authtoken=b6edaf10355ea01a7e26da56265afb63&scope=crmapi&selectColumns=All&searchCondition=(Start%20DateTime|%3E|2014-06-17%2000:00:00) Search Records.......
# $ch = curl_init('https://crm.zoho.com/crm/private/json/Events/getRecords?authtoken=b6edaf10355ea01a7e26da56265afb63&scope=crmapi');
$date = date('Y-m-d');
mysql_query("DELETE from events WHERE date(start_date) > '$date' AND client_id = '$cid'");
$ch = curl_init('https://crm.zoho.com/crm/private/json/Events/getSearchRecords?authtoken='.$z_key.'&scope=crmapi&selectColumns=All&searchCondition=(Start%20DateTime|>|'.$date.')');
curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// Turn off the server and peer verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response)
// curl_setopt($ch, CURLOPT_POST, 1);//Regular post
$response = curl_exec($ch);
curl_close($ch);
$decode = json_decode($response,true);
print_r($decode);
$users = $decode['response']['result']['Events']['row'];
//print_r($users);
foreach($users as $us)
{
//echo $us['FL'][3]['content']." ".$us['FL'][4]['content']." to ".$us['FL'][12]['content'].'<br>';
//print_r($us['FL'][3]['content']);
$details = $us['FL'];
for($i = 0, $l = count($details); $i < $l; ++$i) {
if ($details[$i]['val'] == "Subject")
{ echo $details[$i]['content'].' ';
$name = $details[$i]['content'];
}
if ($details[$i]['val'] == "Start DateTime")
{ echo $details[$i]['content'].' to ';
$start = $details[$i]['content'];
$st = date('Y-m-d',strtotime($start));
}
if ($details[$i]['val'] == "End DateTime")
{ echo $details[$i]['content'].'<br>';
$end = $details[$i]['content'];
}
}
$sql = "INSERT INTO events(event_name,start_date,end_date,client_id) VALUES('$name','$start','$end','$cid')";
$query = mysql_query($sql);
}