Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7803893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:44:04+00:00 2026-06-02T01:44:04+00:00

I wrote a really basic wrapper class for Highrise’s API. It works perfectly for

  • 0

I wrote a really basic wrapper class for Highrise’s API. It works perfectly for Reads (GET), and I’m just starting to test it for Creates (POST). As far as I can tell, these two requests (one on the command line, one via PHP’s cURL library) are identical. Same XML, same options set….just one works, and the other doesn’t.

Any help is appreciated. I posted this question to 37signals developer mailing list also, but stackoverflow is generally faster at spotting my dumb mistakes…

This is the error I get with PHP’s cURL (makes me think Highrise is having a problem parsing the XML string):

<?xml version="1.0" encoding="UTF-8"?> <errors> <error>First name can't be blank</error> </errors> 

This is what works on the command line:

curl -u 'my_api_key:X'
    -H 'Content-type: application/xml'
    -d '<?xml version="1.0" encoding="UTF-8"?> <person><first-name>Savos</first-name><last-name>Aren</last-name><title>Archmage</title><company-name>Winterhold College</company-name><contact-data><email-addresses/><phone-numbers><phone-number><number>555-555-5555</number><location>Home</location></phone-number><phone-number><number>555-555-5555</number><location>Work</location></phone-number><phone-number><number>555-555-5555</number><location>Mobile</location></phone-number></phone-numbers><addresses><address><city>Winterhold</city><country>Tamriel</country><state>Skyrim</state><street>Hall of the Elements, College of Winterhold</street><zip>99999</zip><location>Work</location></address></addresses></contact-data></person>'
    https://myuserid.highrisehq.com/people.xml

Here’s my wrapper class:

class HighriseAPICall {
    protected $_timeout = 120;
    protected $_url_prefix = 'https://';
    protected $_url_suffix = '.highrisehq.com';
    protected $_password = 'X';

    protected $_userpwd;
    protected $_url;

    public function __construct($api_key, $username) {
        $this->_userpwd= $api_key . ':' . $this->_password;
        $this->_url = $this->_url_prefix . $username . $this->_url_suffix;
    }

    /**
     * Make the specified API call.
     * @param string $action one of the four HTTP verbs supported by Highrise
     * @param string $resource_name the Highrise resource to be accessed
     * @param string $xml a well-formed XML string for a Highrise create, update, or delete request
     * 
     * $xml parameter should include any query parameters as suggested by Highrise API documentation
     * eg, if you want to GET all People, pass in "/people.xml"
     * and if you want to get People by search term where field=value,
     * then pass in "/people/search.xml?criteria[field]=value"
     */
    public function makeAPICall($action,$resource_name,$xml=null) {
        /* initialize curl session and set defaults for new API call */
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $this->_url . $resource_name);
        curl_setopt($curl, CURLOPT_USERPWD, $this->_userpwd);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->_timeout);
        /* if xml was passed in, set header and postfields */
        if (isset($xml)) {
            curl_setopt($curl, CURLOPT_HTTPHEADER, 'Content-type: application/xml');
            curl_setopt($curl, CURLOPT_POSTFIELDS, "$xml");
        }
        /* set action as custom request */
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $action);
        /* get the string response from executing the curl session */
        $result = curl_exec($curl);
        curl_close($curl);

        // return the response as a simpleXMLElement
        try {
                $result_simplexml = new SimpleXMLElement($result);
        }
        catch (Exception $e) {
                throw new Exception("Highrise API Call Error: " . $e->getMessage() . ", Response: " . $result);
        }
        if (!is_object($result_simplexml)) {
                throw new Exception("Highrise API Call Error: Could not parse XML, Response: " . $result);
        }
        return $result_simplexml;
    }

}
?>

And the simple testpage I’m using:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
            require_once('HighriseAPICall.class.php');
            $highrise_api_key = 'OBSCURED';
            $highrise_username = 'OBSCURED';
            $highrise_api = new HighriseAPICall($highrise_api_key, $highrise_username);

            $person_xml ='<?xml version="1.0" encoding="UTF-8"?> <person><first-name>Savos</first-name><last-name>Aren</last-name><title>Archmage</title><company-name>Winterhold College</company-name><contact-data><email-addresses/><phone-numbers><phone-number><number>555-555-5555</number><location>Home</location></phone-number><phone-number><number>555-555-5555</number><location>Work</location></phone-number><phone-number><number>555-555-5555</number><location>Mobile</location></phone-number></phone-numbers><addresses><address><city>Winterhold</city><country>Tamriel</country><state>Skyrim</state><street>Hall of the Elements, College of Winterhold</street><zip>99999</zip><location>Work</location></address></addresses></contact-data></person>';

            $response = $highrise_api->makeAPICall('POST', '/people.xml', $person_xml);
            echo htmlentities($response->asXML());
        ?>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:44:07+00:00Added an answer on June 2, 2026 at 1:44 am

    In my wrapper class, the line:

    curl_setopt($curl, CURLOPT_HTTPHEADER, 'Content-type: application/xml');
    

    should have been:

    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/xml'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting some really wierd linking errors from a class I wrote. I am
I'm new in PHP and my question is REALLY basic today. I wrote the
I wrote a function in bash script. However, it's complaining about syntax. I really
I'm trying to write really simple iOS5 app just searching for specific type of
I have another SQL/access 2007 question that seems really basic but I'm not sure
I know that this is really basic, but I looked everywhere and I cant
This seems like a really basic thing that I'm doing, yet I'm tearing my
I'm sure this is really basic but I can't see what I'm doing wrong.
I have created a basic project in to which i have added a really
I'm just getting started with the google maps API and I feel like I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.