New to API programming and am trying to setup eBay to call my website php script when a item is sold.
I would think this is a well document procedure but after reading up on the eBay dev site I'm even more confused. Seems to be a black art in setting this up.
I have setup my account and credentials and have that all working with a phython script to read stock levels, so I know all the dev_id, app_id, cert_id is all working.
If I understand correctly I need to to a API call to eBay to subscribe to notificationswhich I've done with:
!/usr/bin/env python3
import requests
import xml.etree.ElementTree as ET
# Set your eBay API credentials
dev_id = "MY_DEVKEY"
app_id = "MY_APPKEY"
cert_id = "MY_CERTID"
auth_token = "TOKEN"
# Set up the Trading API credentials
api_endpoint = 'https://api.ebay.com/ws/api.dll'
# Set up the request headers
headers = {
'X-EBAY-API-COMPATIBILITY-LEVEL': '1085',
'X-EBAY-API-DEV-NAME': dev_id,
'X-EBAY-API-APP-NAME': app_id,
'X-EBAY-API-CERT-NAME': cert_id,
'X-EBAY-API-CALL-NAME': 'GetItem',
'X-EBAY-API-SITEID': '3',
'Content-Type': 'text/xml'
}
# Set up the request payload
payload = f"""
<?xml version="1.0" encoding="utf-8"?>
<GetNotificationPreferencesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<ApplicationDeliveryPreferences>
<AlertEnable>Enable</AlertEnable>
<ApplicationEnable>Enable</ApplicationEnable>
<ApplicationURL>http://api.mywebsite.co.uk/ebay.php</ApplicationURL>
<DeviceType>Platform</DeviceType>
</ApplicationDeliveryPreferences>
<UserDeliveryPreferenceArray>
<NotificationEnable>
<EventType>ItemSold</EventType>
<EventEnable>Enable</EventEnable>
</NotificationEnable>
</UserDeliveryPreferenceArray>
</GetNotificationPreferencesRequest>
"""
# Send the request to the Trading API
response = requests.post(api_endpoint, headers=headers, data=payload)
print (response)
When I run this I get a 200 response back - so am I correct in assuming the subscription went in ok.
I've just sold a item and have been monitoring my web logs and not seeing any connects.
Any tips on what I'm missing, or any decent beginner links on how to set this up.