2014-11-02 87 views
0

我有以下代码:致命错误:类 '的OAuth' 用C未找到: XAMPP htdocs中 shapeway.php

<?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); 
} 

?> 

,但我得到了以下错误:Fatal error: Class 'oauth' not found in C:\xampp\htdocs\shapeway.php 如果任何人都可以解释我为什么我得到这个错误,我会非常高兴。

回答

1

Insetead的:

$consumer_key = "C:\xampp\htdocs\consumer_key.php"; 

使用:

include 'C:\xampp\htdocs\consumer_key.php'; 

如果在该文件中的变量$consumer_key你是好去。我不得不说,你需要使用相对路径的文件或它不会工作。所以像include 'consumer_key.php';。如果您需要以前文件夹中的文件,请使用include '../file.php';。不要使用\反斜杠文件,这将失败。这还包括图像等。您需要为每个文件执行此操作。

+0

我编辑$ consumer_key包含,但仍然有错误! ,请你张贴编辑后的版本 – 2014-11-02 12:14:44

相关问题