Montag, 23 Oktober 15:38:40

API for Webmasters

This API provides access to manage your ads.
API Config
# URL to API
$url = 'https://ps24.ch/api.php';

# Access to API
$api["api_key"] = "YOUR_API_KEY";

# Action API (add, edit, remove)
$api["action"] = "add";

# Edit and Remove Ad (for remove allowed multiple ids)
$api["id"] = array("AD_ID");

# Test API (boolean) (return correctly filled fields)
$api["test"] = 1;
Add / Edit - Required fields
# AD type 0-2 (int) [ list ] default Premium
$api["type"] = 0;

# Title (string) max length 100
$api["title"] = '';

# Category 0-9 (int) [ list ] default Sie sucht ihn
$api["category"] = 0;

# Phone (string) fill phone or email, one or both of them
$api["phone"] = '';

# Phone code 0-2 (int) [ list ] default CH +41
$api["phone_code"] = 0;

# Email (string) fill email or phone, one or both of them
$api["email"] = '';

# Region 0-26 (int) [ list ] default Ganze Schweiz
$api["region"] = 0;

# Meeting 0-1 (int) array() [ list ]
$api["meet"] = array();

# AD description (text)
$api["text"] = '';
Add / Edit - Not required fields
# Allow SMS (boolean) default disallow
$api["sms"] = 0;

# Home Page URL (string)
$api["url"] = '';

# Street (string)
$api["street"] = '';

# Place (string)
$api["place"] = '';

# Name (string) max length 30
$api["name"] = '';

# Age  18-99 (int) default 0
$api["age"] = 0;

# Language 0-8 (int) array() [ list ]
$api["language"] = array();

# Ethnicity 0-6 (int) [ list ]
$api["typ"] = '';

# Figure 0-2 (int) [ list ]
$api["figure"] = '';

# Bust 0-2 (int) [ list ]
$api["bust"] = '';

# Hair color 0-5 (int) [ list ]
$api["hair"] = '';

# Pubic hair 0-2 (int) [ list ]
$api["pubic"] = '';

# Height 0-2 (int) [ list ]
$api["height"] = '';

# Services 0-24 (int) array() [ list ]
$api["services"] = array();

# Photo (url) max 5 images (JPG/PNG min 200х200px)
$api["image"] = array();

# Schedule 0-6 (int) array() [ list ] default all days of the week
$api["schedule"] = array();

# Remove AD 1-30 (int) default 30 days
$api["remove"] = 30;
Request to API
# Build post data
$data = http_build_query($api);

# Send data via CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$response = curl_exec($ch);
curl_close($ch);
Response - Add AD
{
    "response":[{
        "status": "success",
        "id": AD_ID,
        "url": "https://ps24.ch/anzeige.php?id=AD_ID"
    }]
}
Response - Edit / Remove AD
{
    "response":[{
        "status": "success"
    }]
}
Response - Test # return correctly filled fields
{
    "response":[{
        "status": "test",
        "fields": {
            Required {
                "Title": "Test API",
                "Text": "Hello World!"
            },
            Not required {
                "Name": "Laura",
                "Age": 25
            }
        }
    }]
}
Response - Error
{
    "response":[{
        "status": "error",
        "code": "invalid_api_key"
    }]
}
Response - List errors
access_denied
invalid_api_key
invalid_ip_access
no_data
missing_id
missing_title
wrong_phone
wrong_email
missing_email_or_phone
missing_meet
missing_text
not_enough_credits
ad_not_found
uknown_error
Download API example
API example (PHP)
Get API Key
API Access
Loading...