if ($user === false) {
    print "We were unable to grab the user's profile information<br/>";
} else {
    // get the username from the user object. This will be, for example, pwest. And
    // we can use this in the SPARQL query to get the user's information
    $username = $user->name;
    // sparql query to pull back the user's information. This query is running slow
    // and needs to be sped up. But with all the information we're pulling back I
    // don't see anything to speed up.
    $query = "network_id:{$username}";
    // Initialize the curl object.
    dco_init();
    // Run the query and pull back the json object
    $j = runESQuery($query);
    // no matter if the bindings are returned or not we close the curl object now
    dco_cleanUp();
    if ($j === false) {
        print "We were unable to query for the user's profile information<br/>";
    } else {
        $obj = $j->hits->hits[0]->_source;
        // These divs were pulled from the original view
        print "<div id=\"content-content\" class=\"content-content\">";
        print "<div id=\"view-id-profile_about_page-page_1\" class=\"view view-profile-about-page view-id-profile_about_page view-display-id-page_1 view-dom-id-1 \">";
        print "<div class=\"inner content\">";
        print "<div class=\"view-content\">";
        print "<div class=\"views-row views-row-1 views-row-odd views-row-first views-row-last\">";
        print "";
        // Display the name with a link to the dcoid
        $dcoid = $obj->dcoId;
        $name = $obj->name;
        print "<div class=\"views-field-value-1\">";
예제 #2
0
function runQuery($fullurl, $tryme = 0)
{
    global $curl, $log;
    //fwrite( $log, "query = $query\n" ) ;
    sleep(1);
    //curl_setopt( $curl, CURLOPT_POSTFIELDS, "query=".urlencode( $query ) ) ;
    curl_setopt($curl, CURLOPT_URL, $fullurl);
    // execute the query
    $content = curl_exec($curl);
    // inialize here in case there's a problem with the query, or an
    // empty set
    $results = array();
    // get the http status before we close the curl session
    $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    // the status should be 200 or 303
    //fwrite( $log, "http_status = $http_status\n" ) ;
    if ($http_status != "200" && $http_status != "303") {
        if ($tryme == 1) {
            //fwrite( $log, "http_status = $http_status\n" ) ;
            //fwrite( $log, curl_error( $curl ) ) ;
            dco_cleanUp();
        } else {
            return runQuery($query, 1);
        }
    }
    if (!$content) {
        if ($tryme == 1) {
            //fwrite( $log, "NO CONTENT\n" ) ;
            //fwrite( $log, curl_error( $curl ) ) ;
            dco_cleanUp();
        } else {
            return runQuery($query, 1);
        }
    }
    //fwrite( $log, "content = $content\n" ) ;
    $j = json_decode($content);
    if (!$j) {
        if ($tryme == 1) {
            //fwrite( $log, "decode failed\n" ) ;
            //fwrite( $log, json_last_error_msg() ) ;
            //fwrite( $log, "$content\n" ) ;
            dco_cleanUp();
        } else {
            return runQuery($query, 1);
        }
    }
    return $j;
}