Uncaught ReferenceError: check_url is not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrghull
    Junior Member
    • Sep 2012
    • 2

    #1

    Uncaught ReferenceError: check_url is not defined

    Hi guys,

    Probably a stupid error but can anyone spot it? This code throws the following error in the console:

    PHP Code:
    Uncaught ReferenceError: check_url is not defined 
    It's very hacky at the moment but could do with a pointer! Doesn't do much - opens a table of competitions I'm interested in and then gets the fixtures for that competition (just football matches).

    PHP Code:
    <?php

    $APP_KEY 
    = "REMOVED";
    $SESSION_TOKEN = "REMOVED";

    $DATABASEHOST = "REMOVED";
    $DATABASEUSER = "REMOVED";
    $DATABASEPASSWORD = "REMOVED";
    $DATABASENAME = "REMOVED";

    $DEBUG = true;

    require_once(
    'Mysqlidb.php');

    function 
    writeToLog($message)
    {
        
    $file = $_SERVER['DOCUMENT_ROOT']."/".date("Ymd").".txt";
        
    file_put_contents($file, date("h:m:s")." - ".$message."\n", FILE_APPEND | LOCK_EX);
    }

    function 
    getFixtures($appKey, $sessionToken, $compID)
    {
        
    $jsonResponse = sportsApingRequest($appKey, $sessionToken, 'listEvents', '{"filter":{"competitionIds":["'.$compID.'"],"marketTypeCodes":["MATCH_ODDS"]}}');
        
    m_returnstatus(conn, identifier)rn $jsonResponse[0]->result;
    }

    function 
    sportsApingRequest($appKey, $sessionToken, $operation, $params)
    {
        
    $ch = curl_init();
        
    curl_setopt($ch, CURLOPT_URL, "https://api.betfair.com/exchange/betting/json-rpc/v1");
        
    curl_setopt($ch, CURLOPT_POST, 1);
        
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            
    'X-Application: ' . $appKey,
            
    'X-Authentication: ' . $sessionToken,
            
    'Accept: application/json',
            
    'Content-Type: application/json'
        
    ));

        
    $postData =
            
    '[{ "jsonrpc": "2.0", "method": "SportsAPING/v1.0/' . $operation . '", "params" :' . $params . ', "id": 1}]';

        
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

        
    debug('Post Data: ' . $postData);
        
    $response = json_decode(curl_exec($ch));
        
    debug('Response: ' . json_encode($response));

        
    curl_close($ch);

        if (isset(
    $response[0]->error)) {
            echo 
    'Call to api-ng failed: ' . "\n";
            echo  
    'Response: ' . json_encode($response);
            exit(-
    1);
        } else {
            return 
    $response;
        }

    }

    function 
    debug($debugString)
    {
        global 
    $DEBUG;
        if (
    $DEBUG)
            echo 
    $debugString . "\n\n";
    }

    // ***********************************

    writeToLog("get-fixtures.php start.");

    // get the list of competitions we need fixtures for.
    writeToLog("Get competitions to check for.");

    $db = new Mysqlidb($DATABASEHOST, $DATABASEUSER, $DATABASEPASSWORD, $DATABASENAME);
    $results = $db->rawQuery("SELECT * FROM ta_Competition", $params);
    //print_r($results); // contains array of returned rows

    // loop around the competitions and get the fixtures from Betfair for today, store in db
    $length = count($results);
    for (
    $i = 0; $i < $length; $i++) {

        
    //print_r($results[$i]["CompetitionName"]);
         //print_r($results[$i]["CompetitionID"]);

         // now go to Betfair and get the fixtures for that competition.
         
    $allFixtures = getFixtures($APP_KEY, $SESSION_TOKEN, $results[$i]["CompetitionID"]);
         
    print_r($allFixtures);


    ?>
  • jrghull
    Junior Member
    • Sep 2012
    • 2

    #2
    Fixed. Spotted it.

    Thanks anyway!

    Comment

    Working...
    X