-
Notifications
You must be signed in to change notification settings - Fork 0
/
couchdb.php~
75 lines (65 loc) · 2.49 KB
/
couchdb.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
// Licensed under the Apache License. See footer for details.
//We need to pull in the Sag PHP library. SAG is an open API used to connect to the Cloudant database.
//We only need to do this once!
require('vendor/autoload.php');
//Get Connection Variables from VCAPS_SERVICES. We first need to pull in our Cloudant database
//connection variables from the VCAPS_SERVICES environment variable. This environment variable
//will be put in your project by Bluemix once you add the Cloudant database to your Bluemix
//application.
// vcap_services Extraction
$services_json = json_decode(getenv('VCAP_SERVICES'),true);
$VcapSvs = $services_json["cloudantNoSQLDB"][0]["credentials"];
// Extract the VCAP_SERVICES variables for Cloudant connection.
$myUsername = $VcapSvs["username"];
$myPassword = $VcapSvs["password"];
try {
// Let's login to the database.
$sag = new Sag($myUsername . ".cloudant.com");
$sag->login($myUsername, $myPassword);
// Now that we are logged in, we can create a database to use
//$sag->createDatabase("ttpfeedback");
$sag->setDatabase("ttpfeedback");
/****feedback document starts ****/
$namee=$_POST["name"];
$com=$_POST["com"];
$tweet=$_POST["tweet"];
$acc=$_POST["service"];
$sw=$_POST["topic"];
$text=$_POST["text"];
$rating=$_POST["rating"];
/**test starts**/
$ch = curl_init();
$customer = array(
'EmailID' => $tweet,
'Organization' => $com,
'Rating' => $rating,
'Service' => $acc,
'Topics' => $sw,
'comments' => $text
);
$sag->put('"'.$namee.'"', $customer);
/** feedback document ends **/
}
catch(Exception $e) {
//We sent something to Sag that it didn't expect.
echo '<p>There Was an Error Getting Data from Cloudant!!!</p>';
echo $e->getMessage();
}
echo "Thank you..".$namee."..for the Feedback !! ";
//-------------------------------------------------------------------------------
// Copyright IBM Corp. 2014
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//-------------------------------------------------------------------------------
?>