Fatal error: require(): Failed opening required ‘WP_DIRwp-blog-header.php’

I am a game developer, not very familiar with web programming. I am trying to tie my website point system, MyCred, into my games. Mycred has code snippets for interacting with the points from another site. I use their snippet, but I keep getting this error:

Fatal error: require(): Failed opening required ‘WP_DIRwp-blog-header.php’ (include_path=”.:/usr/lib/php7.2″) in /homepages/24/d773619225/htdocs/clickandbuilds/SefronGames/Gameconnect/KC.php on line 2

I have searched the web and tried adding code to top to load the wp, but doesn’t work. Still throws the error. Here is the php code I am having an issue with:

<?php
require WP_DIR.'wp-blog-header.php';
$secret_key = 'I took this off to protect info';
$remote_url="I took this off to protect info ";

$action     = 'CREDIT';
$account="[email protected]";
$amount     = 10;
$ref="reference";
$ref_id     = 0;
$entry      = 'Points for viewing video';
$data="optional extra";
$point_type="Kanobia Credit";
$host       = get_bloginfo( 'url' );

$token      = md5( $host . $action . $amount . $secret_key );

$request    = array(
    'method' => 'POST',
    'body'   => array(
        'action'  => $action,
        'account' => $account,
        'amount'  => $amount,
        'ref'     => $ref,
        'ref_id'  => $ref_id,
        'type'    => $point_type,
        'entry'   => $entry,
        'data'    => $data,
        'token'   => $token,
        'host'    => $host
    )
);

$response = wp_remote_post( $remote_url, $request );
?>

2 Answers
2

It looks as though WP_DIR is being interpreted as a string. Is that constant defined anywhere before this code is being run?

My guess is that it is not as PHP will assume it’s a string and that is why the location is WP_DIRwp-blog-header.php and not an actual file path.

Hope this helps!

Leave a Comment