[英]Fatal error: Class 'oauth' not found in C:\xampp\htdocs\shapeway.php
I have the following code: 我有以下代码:
<?php
$consumer_key="C:\xampp\htdocs\consumer_key.php";
$access_token="C:\xampp\htdocs\access_token.php";
$api_url_base="C:\xampp\htdocs\api_url_base.php";
$error="C:\xampp\htdocs\error.php";
try {
$consumer_key="C:\xampp\htdocs\consumer_key.php";
$access_token="C:\xampp\htdocs\access_token.php";
$api_url_base="C:\xampp\htdocs\api_url_base.php";
$error="C:\xampp\htdocs\error.php";
include "oauth.php";
//***************************************************************************************************
$oauth = new oauth($consumer_key, $consumer_secret, OAUTH_SIG_METHOD_HMACSHA1,
OAUTH_AUTH_TYPE_AUTHORIZATION);
//***************************************************************************************************
$oauth->enableDebug();
$oauth->setToken($access_token, $access_secret);
} catch(OAuthException $E) {
Error("setup exception", $E->getMessage(), null, null, $E->debugInfo);
}
try {
$api_url_base="C:\xampp\htdocs\api_url_base.php";
$error="C:\xampp\htdocs\error.php";
$filename = "www.sim3dmodel.com/example2.stl";//cube-1cm3-centered_in_meter.stl
$file = file_get_contents("../models/". $filename);
$data = array("fileName" => "$filename",
"file" => rawurlencode(base64_encode($file)),
"hasRightsToModel" => 1,
"acceptTermsAndConditions" => 1,
);
$data_string = json_encode($data);
$oauth->fetch($api_url_base ."/models/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
PrintJsonLastError();
var_dump($response);
} else {
print_r($json);
}
} catch(OAuthException $E) {
Error("fetch exception", $E->getMessage(), null, $oauth->getLastResponseInfo(), $E->debugInfo);
}
?>
But I get the following error: Fatal error: Class 'oauth' not found in C:\\xampp\\htdocs\\shapeway.php
If anyone could explain me why I get this error I would be very happy. 但是我收到以下错误: Fatal error: Class 'oauth' not found in C:\\xampp\\htdocs\\shapeway.php
如果有人可以解释我为什么会出现此错误,我将非常高兴。
Insetead of: 的精神:
$consumer_key = "C:\xampp\htdocs\consumer_key.php";
use: 采用:
include 'C:\xampp\htdocs\consumer_key.php';
If you have a variable $consumer_key
in that file you are good to go. 如果在该文件中有变量$consumer_key
,则可以使用。 I have to say that you need to use a relative path to the file or it won't work. 我不得不说,您需要使用文件的相对路径,否则它将无法正常工作。 So something like include 'consumer_key.php';
这样的东西include 'consumer_key.php';
. 。 If you need a file from a previous folder use include '../file.php';
如果您需要以前文件夹中的文件,请使用include '../file.php';
. 。 Don't use \\
backslashes for files this will fail. 不要对文件使用\\
反斜杠,否则将失败。 This also includes images etc. You need to do this for every file. 这也包括图像等。您需要对每个文件执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.