forked from rdehler/php-oauth-salesforce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
longer_than_x.php
52 lines (43 loc) · 1.57 KB
/
longer_than_x.php
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
<?php
session_start();
function do_select($instance_url, $access_token) {
$query = "select id, name from contact limit 100";
$url = "$instance_url/services/data/v20.0/query?q=" . urlencode($query);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Authorization: OAuth $access_token"));
$json_response = curl_exec($curl);
curl_close($curl);
$response = json_decode($json_response, true);
$total_size = $response['totalSize'];
echo "$total_size record(s) returned<br/><br/>";
foreach ((array) $response['records'] as $record) {
echo $record['Id'] . ", " . $record['Name'] . "<br/>";
}
echo "<br/>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Longer than X Employees</title>
</head>
<body>
<tt>
<?php
$access_token = $_SESSION['access_token'];
$instance_url = $_SESSION['instance_url'];
if (!isset($access_token) || $access_token == "") {
die("Error - access token missing from session!");
}
if (!isset($instance_url) || $instance_url == "") {
die("Error - instance URL missing from session!");
}
do_select($instance_url, $access_token);
?>
</tt>
</body>
</html>