Welcome‎ > ‎Version 3‎ > ‎Publisher Api‎ > ‎Methods‎ > ‎4 - Publisher Related‎ > ‎

Get Closest Segment

Will retrieve the geographically closest segment to the location in the query string.  Exactly one of Address, IPAddress, or (Latitude, Longitude) must be provided.  The return value closestSegment will be null if no segment was found matching the query string parameters.

The Latitude and Longitude of the input is compared against the Segment.Location as defined inside PubAdmin.

Method: GET /api/v3/publisher/segment
Authentication: oauth
 
Parameters
Required QueryString Value
Explanation
No
Address
If this is provided, the segment with the closest location to the location of this street address will be returned.  The address field is free form, so there are no specific requirements on its content.  For example, "628 Broadway NYC" "11218" and "Texas" are all valid inputs.
No
IPAddress If this is provided, the segment with the closest location to the location of the machine with this ip address will be returned.
No Latitude
If this is provided (along with longitude), the segment with the closest location to this (latitude, longitude) pair will be returned.
NoLongitude
see above
No
MaxKilometers
If no segment is found within this many kilometers of the provided location, the returned segment will be null.  If not provided, there is no limit on the distance between the query location and the segment location.
No
MaxMiles
If no segment is found within this many miles of the provided location, the returned segment will be null.  If max kilometers is provided, max miles will be ignored.

Returns
base response fields
closestSegment - The closest segment to the location in the query string.

Sample Request:

GET  http://api.groupcommerce.com/api/v3/publisher/segment?IPAddress=72.229.174.215&MaxKilometers=10000

Authorization: OAuth oauth_signature="7Z3DfnySXd6ibmDKzNDlb5%2bAvz0%3d", oauth_nonce="3502803", oauth_timestamp="1330554994", oauth_consumer_key="eeb6b959-b854-4ad1-b563-e801c83cf81d", oauth_signature_method="HMAC-SHA1", oauth_version="1.0"

Sample JSON Response:

{
    "errors": [],
    "lastPublished": "/Date(1330554857431)/",
    "success": true,
    "version": "3",
    "closestSegment": {
        /*
see segment */
    }
}


Sample XML Response:

<getClosestSegmentResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <errors />
  <lastPublished>2012-02-29T22:35:00.5891689Z</lastPublished>
  <success>true</success>
  <version>3</version>
  <closestSegment>
    <!-- see segment -->
  </closestSegment>
</getClosestSegmentResponse>
Comments