0

Okay so the basically I'm building an application to connect to xero on the activecollab framework. And I'm testing the xeroapi php script created by David Pitman. And I'm just trying to find out why my browser responds with The connection to the server was reset while the page was loading. (but doesn't generated any liveheaders nor does firebug pick anything up)...

thumb
(source: iforce.co.nz)

Here is a snippet of code, that is being used. (Everything has been setup prior using the XERO Api previewer and openssl.)

    define('XERO_KEY','my-key-here'); //hidden for privacy reasons
    define('XERO_SECRET','my-key-here'); //hidden for privacy reasons
    define('XERO_PUBLIC_KEY_PATH', 'path/to/public.key');
    define('XERO_PRIVATE_KEY_PATH', 'path/to/privatekey.pem');

    $xero = new Xero(XERO_KEY, XERO_SECRET, XERO_PUBLIC_KEY_PATH, XERO_PRIVATE_KEY_PATH, 'xml' );  
    $organisation = $xero->organisation;  

    //echo the results back  
    if ( is_object($organisation) ) {  
    //use this to see the source code if the $format option is "xml"  
    echo htmlentities($organisation->asXML()) . "<hr />";  
    } else {  
    //use this to see the source code if the $format option is "json" or not specified  
    echo json_encode($organisation) . "<hr />";  
    }

And my problem is... that the error_log (php) doesn't display any errors a part from a warning:

2012-07-23 21:59:42 Notice : Undefined index: port (at C:\xampp\htdocs\ac3\activecollab\3.1.10\modules\xero_invoice_manager\lib\xero\xero.class.php on 644 line)

The code on xero.class.php line 644

/**
* parses the url and rebuilds it to be
* scheme://host/path
*/
public function get_normalized_http_url() {
$parts = parse_url($this->http_url);

$port = @$parts['port']; //this line says its undefined
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = @$parts['path'];

$port or $port = ($scheme == 'https') ? '443' : '80';

if (($scheme == 'https' && $port != '443')
    || ($scheme == 'http' && $port != '80')) {
  $host = "$host:$port";
}
return "$scheme://$host$path";
}

From investigating I've found on print_r the result of $parts in a preformatted tag is..

Array
(
    [scheme] => https
    [host] => api.xero.com
    [path] => /api.xro/2.0/Organisation
)

The same information is used on a live server (for the past couple of months). but the xeroapi class is not working on the test server, does anyone have any advice as to why it isn't connecting? I'm running XAMPP Control Panel with apache on port 80 and PHP Version 5.3.8.

4

1 回答 1

1

我不确定你的端口问题。

但是,Xero API 需要 OAuth 设置,这可能是在 Xero 类中为您完成的。OAuth 的一部分内容是设置回调域,这需要您向 Xero 注册一个回调域。Xero 允许您使用注册域的子域,我假设 Xero 类使用请求信息来设置正确的域。

在 localhost 上,该域是 localhost,它不是子域。你可以注册 localhost,或者做我做过的事情(因为我无权访问 Application 帐户),并在你的 hosts 文件中设置一个特殊的本地子域。

因此,如果您使用example.com.,那么一个好的“本地”域是local.example.com. 希望有帮助。

于 2012-07-23T22:24:44.197 回答