0

我正在尝试将 PHP Wrapper 用于位于此处的 Highrise API:

https://github.com/ignaciovazquez/Highrise-PHP-Api

我需要为 HighrisePerson 对象设置一个自定义字段。根据代码,这应该非常简单......

$person->setCustomField("Field Name", $value); // Pulled almost straight out of the documentation

不幸的是,当我尝试将其保存回高层时,$person->save();我收到以下错误:

Uncaught exception 'Exception' with message 'API for Person returned Status Code: 500 Expected Code: 200'

所以错误不在代码中...... Highrise 只是不接受自定义字段。关于为什么会这样的任何想法?

4

2 回答 2

0

为了通过 Highrise-PHP-Api 使用37signals 应该提供一个帐户名和访问令牌;

$hr = new HighriseAPI();
$hr->setAccount("accountname");
$hr->setToken("token");

然后你可以执行你的其他功能

$person->setCustomField("Field Name", $value);

如果您仔细查看此 api 的测试,您会看到;

if (count($argv) != 3)
        die("Usage: php users.test.php [account-name] [access-token]\n");
于 2014-01-23T07:46:15.287 回答
0

好吧...我想通了...

在 API 中如下:

$person->setCustomField("字段名称", $value);

在 Highrise 中创建一个新的自定义字段。因此,如果还没有名为“字段名称”的自定义字段,它将创建它。如果该字段已存在,则返回 500 错误。

据我所知,无法使用该包装器设置现有字段的值。您只能创建新字段,这有点麻烦。

我从包装纸上找到了一个对我来说效果很好的叉子。它托管在这里:https ://github.com/AppSaloon/Highrise-PHP-Api

这个用法令人困惑,我花了一段时间才弄清楚。

基本上,您想搜索 Highrise 中的所有自定义字段。一旦你找到你想要的,你给它分配必要的值......所以代码看起来像这样:

// Load up all the custom fields out of Highrise
    $cfields = $highrise->findAllCustomfields();

// Search each custom field until we find the "Field Name" one. When we do, add it to our Highrise Person.
    foreach ($cfields as $c) {
        if ($c->getSubjectFieldLabel() == "Field Name") 
        {
            // Assign that custom field to the person
            $highrisePerson->addCustomfield($c, "Field Value");
        }
    }

我希望这可以帮助遇到同样问题的其他人。我从另一个 Stack Overflow 问题中发现了分叉的 PHP 包装器,但他们也无法让自定义字段工作。

于 2014-01-25T20:14:55.443 回答