Created
July 9, 2015 15:51
-
-
Save ukmadlz/811921d5fb07178f9599 to your computer and use it in GitHub Desktop.
A post to /gremlin with Bluemix credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Sent a gremlin query | |
*/ | |
// Grab the config | |
$config = json_decode(file_get_contents('config.json')); | |
// Gremlin URL | |
$url = $config->credentials->apiURL . "/gremlin"; | |
// Query Object | |
$query = new stdClass(); | |
$query->gremlin = "g.V()"; | |
// Make the cURL request | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HEADER, 1); | |
curl_setopt($ch, CURLOPT_USERPWD, $config->credentials->username . ":" . $config->credentials->password); | |
curl_setopt($ch, CURLOPT_URL, $url ); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); | |
curl_setopt($ch, CURLOPT_POST, 1 ); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query) ); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); | |
$result=curl_exec ($ch); | |
var_dump($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment