from requests_oauthlib import OAuth1Session
class IS24RestClient():
__config = None
def __init__(self):
self.__call_service()
def __call_service(self):#, url, request="", requestMethod="GET", multipart=''):
session = OAuth1Session(Config.CLIENT_KEY,
client_secret=Config.CLIENT_SECRET,
resource_owner_key=Config.RESOURCE_OWNER_KEY,
resource_owner_secret=Config.RESOURCE_OWNER_SECRET)
url = Config.BASEURL+'user/testkunde/realestate'
print('URL: ' + url)
response = session.get(url)
print('RESPONSE: ' + str(response))Code hier eingeben...
'''
Created on 31.03.2014
@author: Richard Neumann
'''
#
# TODO: Merge into interfaces.is24
#
import urllib
from requests_oauthlib import OAuth1Session
class Config():
BASEURL = 'http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/'
CLIENT_KEY = 'testzugang[..]'
CLIENT_SECRET = 'ChKc[..]'
RESOURCE_OWNER_KEY = 'c4364b3[..]'
RESOURCE_OWNER_SECRET = 'U%2FtUlp[..]'
class IS24RestClient():
__config = None
def __init__(self):
self.__call_service()
def __call_service(self):
session = OAuth1Session(Config.CLIENT_KEY,
client_secret=Config.CLIENT_SECRET,
resource_owner_key=Config.RESOURCE_OWNER_KEY,
resource_owner_secret=Config.RESOURCE_OWNER_SECRET)
url = Config.BASEURL+'user/testkunde/realestate'
print('URL: ' + url)
response = session.get(url)
print('RESPONSE: ' + str(response))
Python 2.7.5 (default, Feb 19 2014, 13:47:28)
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from restapi import IS24RestClient
>>> rc = IS24RestClient()
URL: http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/testkunde/realestate
RESPONSE: <Response [401]>
>>>
'''
Created on 31.03.2014
@author: Richard Neumann
'''
#
# TODO: Merge into interfaces.is24
#
from rauth import OAuth1Service
class IS24RestClient():
__config = None
def __init__(self):
self.__call_service()
def __call_service(self):
is24rest = OAuth1Service(
name='is24rest',
consumer_key='testzugang-homeinfoKey',
consumer_secret='<veryverysecret>',
request_token_url='http://rest.immobilienscout24.de/restapi/security/oauth/request_token',
access_token_url='http://rest.immobilienscout24.de/restapi/security/oauth/access_token',
authorize_url='http://rest.immobilienscout24.de/restapi/security/oauth/confirm_access',
base_url='http://rest.immobilienscout24.de/restapi/api')
request_token, request_token_secret = is24rest.get_request_token('oauth_callback=oob')
print("\n\nFOO:\n")
print(str(request_token) + ' / ' + str(request_token_secret))
homiectl: KeyError('Decoder failed to handle oauth_token with data as returned by provider. A different decoder may be needed. Provider returned: <html><head><title>Apache Tomcat/7.0.52 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 405 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The specified HTTP method is not allowed for the requested resource.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.52</h3></body></html>',)
for help use --help
[neumannr@neumann-homeinfo homie]$ sudo /usr/local/sbin/homiectl -t goo
Request Token: 14524189-9998-4e1c-ae26-a7c4b0edf674
Request Token Secret: 06z92g2JucDWUZo5B7OCM9TszLSnzgwz4y3K5TyNt9OfNPobtNMzoFMJ2cyl0MELcd2Hqf9ib6qDpLIgJii/3gnZmH9TkVdmnC9g7XknlSY=
Visit https://rest.sandbox-immobilienscout24.de/restapi/security/oauth/confirm_access?oauth_token=14524189-9998-4e1c-ae26-a7c4b0edf674 in new browser window.
Enter oauth_verifier here: 6hYP6z
Access Token: 21b786bb-c784-4f60-a090-f1272d466295
Access Token Secret: GmvwP1wnmgPUpeYUNIWGR9GfDrr31W3pJ8R7V5DEWpWx+quWg8mHSs8EHVXmczocMmG0lyaJqP3VLXvuzdPb0V9KrgI4jGZtoj+obkrOpBw=
[neumannr@neumann-homeinfo homie]$
<Response [401]>
/usr/local/sbin/homiectl rest session
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<realestates:apartmentRent xmlns:ns2="http://rest.immobilienscout24.de/schema/platform/gis/1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:common="http://rest.immobilienscout24.de/schema/common/1.0" xmlns:realestates="http://rest.immobilienscout24.de/schema/offer/realestates/1.0" id="62409484">
<externalId>1</externalId>
<title>Testanzeige</title>
<creationDate>2014-04-07T13:35:33.000+02:00</creationDate>
<lastModificationDate>2014-04-24T13:54:13.000+02:00</lastModificationDate>
<address>
<street>Melanchthtonstraße</street>
<houseNumber>7</houseNumber>
<postcode>30165</postcode>
<city>Hannover</city>
<wgs84Coordinate>
<latitude>52.39768</latitude>
<longitude>9.72186</longitude>
</wgs84Coordinate>
<geoHierarchy>
<continent>
<geoCodeId>1</geoCodeId>
<fullGeoCodeId>1</fullGeoCodeId>
</continent>
<country>
<geoCodeId>276</geoCodeId>
<fullGeoCodeId>1276</fullGeoCodeId>
</country>
<region>
<geoCodeId>9</geoCodeId>
<fullGeoCodeId>1276009</fullGeoCodeId>
</region>
<city>
<geoCodeId>17</geoCodeId>
<fullGeoCodeId>1276009017</fullGeoCodeId>
</city>
<quarter>
<geoCodeId>60</geoCodeId>
<fullGeoCodeId>1276009017060</fullGeoCodeId>
</quarter>
<neighbourhood>
<geoCodeId>3241001000215</geoCodeId>
</neighbourhood>
</geoHierarchy>
</address>
<realEstateState>ACTIVE</realEstateState>
<groupNumber>1</groupNumber>
<attachments xlink:href="http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/homeinfo.de/realestate/62409484/attachment"/>
<showAddress>false</showAddress>
<contact id="59391004"/>
<common:publishChannels>
<publishChannel id="10000" title="ImmobilienScout24"/>
</common:publishChannels>
<apartmentType>ROOF_STOREY</apartmentType>
<floor>2</floor>
<lift>false</lift>
<energyCertificate>
<energyCertificateCreationDate>FROM_01_MAY_2014</energyCertificateCreationDate>
<energyEfficiencyClass>E</energyEfficiencyClass>
</energyCertificate>
<cellar>YES</cellar>
<handicappedAccessible>NOT_APPLICABLE</handicappedAccessible>
<condition>NO_INFORMATION</condition>
<constructionYearUnknown>false</constructionYearUnknown>
<constructionYear>1337</constructionYear>
<heatingTypeEnev2014>GAS_HEATING</heatingTypeEnev2014>
<energySourcesEnev2014>
<energySourceEnev2014>ACID_GAS</energySourceEnev2014>
</energySourcesEnev2014>
<buildingEnergyRatingType>ENERGY_REQUIRED</buildingEnergyRatingType>
<thermalCharacteristic>123</thermalCharacteristic>
<energyConsumptionContainsWarmWater>NOT_APPLICABLE</energyConsumptionContainsWarmWater>
<numberOfFloors>2</numberOfFloors>
<usableFloorSpace>60.00</usableFloorSpace>
<numberOfBedRooms>1</numberOfBedRooms>
<numberOfBathRooms>1</numberOfBathRooms>
<guestToilet>NOT_APPLICABLE</guestToilet>
<baseRent>100.00</baseRent>
<totalRent>123.00</totalRent>
<serviceCharge>32.00</serviceCharge>
<heatingCosts>42.00</heatingCosts>
<heatingCostsInServiceCharge>YES</heatingCostsInServiceCharge>
<petsAllowed>NO_INFORMATION</petsAllowed>
<useAsFlatshareRoom>YES</useAsFlatshareRoom>
<livingSpace>60.00</livingSpace>
<numberOfRooms>3</numberOfRooms>
<energyPerformanceCertificate>true</energyPerformanceCertificate>
<builtInKitchen>true</builtInKitchen>
<balcony>false</balcony>
<certificateOfEligibilityNeeded>false</certificateOfEligibilityNeeded>
<garden>true</garden>
<courtage>
<hasCourtage>NO</hasCourtage>
</courtage>
</realestates:apartmentRent>