RESTfulAPIに接続する必要があります。会社がAPIに接続するために私に与えた唯一の例は、Pythonの例です。私は言語を理解していませんが、PHPには慣れています。cuRLやPHPでこれを行う方法はありますか?
Pythonの例を次に示します。
import requests
import hmac
import hashlib
import datetime as dt
import simplejson as json
import sys
tech_prefix = '' #the Account Tech Prefix
secret_key = '' #the API Key
#creating URI info
t = dt.datetime.utcnow().replace(microsecond=0)
timestamp = t.isoformat()
url_scheme = 'https'
net_location = 'api.thesite.com'
path = '/v1/available-tns/npas/'
method = 'GET'
ordered_query_params = ''
body = ''
body_md5 = ''
canonical_uri = url_scheme + "://" + net_location + path + "\n" + ordered_query_params
tokens = (
timestamp,
method,
body_md5,
canonical_uri
)
message_string = u'\n'.join(tokens).encode('utf-8')
signature = hmac.new(secret_key, message_string, digestmod=hashlib.sha1).hexdigest()
headers = {'X-Timestamp':timestamp}
request_url = url_scheme + '://' + net_location + path + '?' + ordered_query_params # append ordered query params here
request = requests.get(request_url,auth=(tech_prefix,signature),headers=headers)
print request