twsowerby Posted January 20, 2009 Share Posted January 20, 2009 Hi all, Ok I cant figure something out. I have this code: <?php $vars = array('user'=>'demo', 'password'=>'demo', 'skey'=>'abc123', 'request'=>'Dashboard', 'userID'=>'2'); $data = apiGetD($vars); function apiGetD($vars) { $accessURL = 'www.eve-tool.com'; $apiURL = '/api/class/class.access.php'; $poststring = http_build_query($vars); $fp = fsockopen($accessURL, 80); fputs($fp, "POST " . $apiURL . " HTTP/1.0\r\n"); fputs($fp, "Host: " . $accessURL . "\r\n"); fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); fputs($fp, "User-Agent: PHPApi\r\n"); fputs($fp, "Content-Length: " . strlen($poststring) . "\r\n"); fputs($fp, "Connection: close\r\n\r\n"); if (strlen($poststring) > 0) fputs($fp, $poststring . "\r\n"); $contents = ""; while (!feof($fp)) { $contents .= fgets($fp); } fclose($fp); $start = strpos($contents, "\r\n\r\n"); if ($start !== false) { return substr($contents, $start + strlen("\r\n\r\n")); } } print_r($data); ?> Which is meant to connect to a class on another server and return an array. When I run it in a standalone "test.php" file on the same server as my drupal installation it works perfectly and I get the correct return. If I then take that exact same code and insert it into a drupal block with the php filter on, it doesnt seem to be sending the "skey" variable and I get this pre-programmed error array back: Array ( [0] => Array ( [message] => Authorization fail. [user] => demo [request] => [iP] => 74.208.43.153 [stamp] => 1232445084 ) [1] => Array ( [message] => No siteKey found. [user] => demo [request] => [iP] => 74.208.43.153 [stamp] => 1232445084 ) ) Note the "No siteKey found" error. Does anyone have any idea what might be messing this up? Or a way around it that I could try? Cheers, Tom Quote Link to comment Share on other sites More sharing options...
ashell Posted January 20, 2009 Share Posted January 20, 2009 Nothing very specific shows up in Google or on the Drupal forum searches. From looking around, it appears the siteKey has something to do with multi-site usage with Drupal. This could have something to do with security from Drupal and the multi-site functionality. Quote Link to comment Share on other sites More sharing options...
twsowerby Posted January 20, 2009 Author Share Posted January 20, 2009 Hmmm the sitekey variable I'm using is just used for passing a value into the class which sits on another server, surely it cant be conflicting with any Drupal sitekeys? The error message im getting is nothing to do with drupal, its an array that is returned from a standalone function when it cant reference the value being passed in. Quote Link to comment Share on other sites More sharing options...
ashell Posted January 20, 2009 Share Posted January 20, 2009 You noted that you are dropping it into a drupal block when you get the error. Without seeing the code from your class, I can't tell for sure. I found a couple posts on drupal talking about a multi-site key, you noted cross server class calls, which I why I pointed that out. If you get it, please post your findings. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.