Skip to content

Instantly share code, notes, and snippets.

@ukmadlz
Created July 9, 2015 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ukmadlz/811921d5fb07178f9599 to your computer and use it in GitHub Desktop.
Save ukmadlz/811921d5fb07178f9599 to your computer and use it in GitHub Desktop.
A post to /gremlin with Bluemix credentials
<?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