Integrate the Social Profiles API in PHP

November 16, 2026
Integrate the Social Profiles API in PHP

You’re building a PHP service that enriches signups or audits where your ads run and you need to attach verified social profiles to each domain reliably and at scale. By the end of this guide, you’ll have a working PHP integration that queries Klazify’s Social Profiles API for any domain, stores the results safely, and plugs them into your data pipeline with caching, batching, and fallback strategies.

Why Klazify is the best fit for social profile enrichment

When you need to resolve accurate social URLs for a domain, false positives and stale links can silently break your workflows. Klazify combines site content analysis with domain signals to surface the right social profiles and pairs this with the same platform that powers categorization and company intelligence, so you can keep one integration for multiple enrichment steps in your pipeline.

Illustration: Integrate the Social Profiles API in PHP
  • Accurate detection of official profiles: Klazify analyzes the site itself to discover and validate official links, reducing misclassification and unofficial handles that often creep in from scraped aggregators.
  • Global coverage: It works across languages and regions, so your enrichment holds up whether you onboard domains from LATAM, EMEA, or APAC.
  • Real-time lookups: You can request fresh detection when you ingest a new domain rather than waiting for bulk database refreshes.
  • IAB taxonomy on tap: If you also need brand safety or contextual controls for the very same domains, you can map results to IAB categories using the same API surface.
  • Simple REST integration: A single JSON POST retrieves social profiles. The response is predictable: each platform is either a valid URL or null.
  • Compliance and filtering: Combine profile detection with category-based filtering to block risky domains in your ad ops or content filters without building separate pipelines.

What the Social Profiles endpoint returns

Use the Social Profiles endpoint to resolve a domain’s official profiles for these platforms:

  • Facebook
  • X
  • Instagram
  • YouTube
  • LinkedIn
  • GitHub
  • Pinterest
  • Medium

Each platform appears as a field in the JSON response. If Klazify cannot find a profile, its value is null. This makes your logic straightforward: treat null as “missing” without guesswork or string parsing.

Quickstart with cURL (copy-paste ready)

Send a POST request with a Bearer token and a JSON payload containing a single key: url.

curl -X POST "https://www.klazify.com/api/domain_social_media" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://cbsnews.com"}'

Notes:

  • Replace YOUR_API_KEY with your actual token.
  • Failed or unreachable calls are not billed.
  • Use HTTPS and set Content-Type to application/json.

Step-by-step PHP integration

The following PHP example uses cURL to request social profiles, handle nulls safely, and normalize output for storage. You can adapt it to Guzzle or Symfony HTTP Client as needed.

<?php
function fetchSocialProfiles(string $apiKey, string $domainUrl, int $timeout = 10): array {
    $endpoint = "https://www.klazify.com/api/domain_social_media";

    $payload = json_encode(["url" => $domainUrl]);
    $ch = curl_init($endpoint);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer {$apiKey}",
            "Content-Type: application/json"
        ],
        CURLOPT_POSTFIELDS => $payload,
        CURLOPT_TIMEOUT => $timeout
    ]);

    $response = curl_exec($ch);
    $curlErr  = curl_error($ch);
    $status   = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($curlErr) {
        // Not billed for unreachable calls; log and retry or fallback.
        throw new RuntimeException("Transport error: " . $curlErr);
    }
    if ($status < 200 || $status >= 300) {
        // Handle non-2xx responses with backoff; decide on retry policy by your queueing system.
        throw new RuntimeException("Unexpected HTTP status: {$status} - {$response}");
    }

    $json = json_decode($response, true);
    if (!is_array($json)) {
        throw new RuntimeException("Invalid JSON response");
    }

    // Normalize expected platforms. Missing or null values indicate "no profile found".
    $platforms = [
        "facebook",
        "x",
        "instagram",
        "youtube",
        "linkedin",
        "github",
        "pinterest",
        "medium"
    ];

    $result = ["domain" => $domainUrl];
    foreach ($platforms as $p) {
        $result[$p] = $json[$p] ?? null; // Preserve nulls
    }

    return $result;
}

// Example usage
try {
    $profiles = fetchSocialProfiles("YOUR_API_KEY", "https://example.com");
    // Persist: upsert into your enrichment table, keyed by domain's registrable root.
    // Cache: store JSON for 7-30 days, invalidate when you re-crawl the site.
    print_r($profiles);
} catch (Throwable $e) {
    error_log($e->getMessage());
    // Fallback: schedule retry with exponential backoff.
}

How to use the results:

  • CRM enrichment: attach non-null fields (e.g., linkedin) to company records.
  • Brand safety: cross-check profiles for verification signals within your own logic.
  • Ad ops: prefer official YouTube or X profiles for creative partnerships; ignore nulls.

Node.js example for batch workers (optional)

If you also run Node-based workers, here is a concise JavaScript snippet. It follows the same structure: POST a JSON body and read platform fields, which may be URLs or nulls.

import fetch from "node-fetch";

async function fetchSocialProfiles(apiKey, domainUrl) {
  const res = await fetch("https://www.klazify.com/api/domain_social_media", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ url: domainUrl })
  });

  if (!res.ok) {
    const text = await res.text();
    throw new Error(`HTTP ${res.status}: ${text}`);
  }

  const json = await res.json();
  const platforms = ["facebook", "x", "instagram", "youtube", "linkedin", "github", "pinterest", "medium"];
  const out = { domain: domainUrl };
  for (const p of platforms) out[p] = json[p] ?? null;
  return out;
}

// Example
fetchSocialProfiles("YOUR_API_KEY", "https://example.com")
  .then(console.log)
  .catch(console.error);

Understanding Klazify responses (official JSON example)

The example below shows a complete response object you’ll encounter when you also use the main categorization endpoint in the same pipeline. It demonstrates how categorization, company data, logo discovery, technology tags, and related domains come back in a single, structured payload. This is useful if you classify a domain and enrich it in one pass, then separately call the Social Profiles endpoint to add handles.


{
    "domain": {
        "categories": [
            {
                "confidence": 0.92,
                "name": "/Computers & Electronics/Consumer Electronics",
                "IAB-632-596": "Consumer Electronics/Technology & Computing/Consumer Electronics"
            },
            {
                "confidence": 0.89,
                "name": "/Internet & Telecom/Mobile & Wireless/Mobile Phones"
            }
        ],
        "social_media": null,
        "logo_url": "https://klazify.s3.amazonaws.com/2110787991611585019600ed5fb1d1300.04730104.png"
    },
    "success": true,
    "objects": {
        "company": {
            "url": "https://www.apple.com/",
            "name": "Apple",
            "city": "Cupertino",
            "stateCode": "CA",
            "countryCode": "US",
            "employeesRange": "100K+",
            "revenue": 274515000000,
            "raised": null,
            "tags": [
                "E-commerce",
                "Consumer Electronics",
                "Mobile",
                "B2C"
            ],
            "tech": [
                "omniture_adobe_analytics",
                "atlassian_confluence",
                "successfactors",
                "apache_apex",
                "talend",
                "oracle_peoplesoft",
                "salesforce",
                "stripe",
                "dell_boomi_atomsphere",
                "gigya",
                "sage_50cloud",
                "quickbooks",
                "webmethods",
                "apache_tomcat",
                "alteryx",
                "tibco_rendezvous",
                "atlassian_jira",
                "..."
            ]
        }
    },
    "domain_registration_data": {
        "domain_age_date": "1987-02-19",
        "domain_age_days_ago": "13026",
        "domain_expiration_date": "2030-02-20",
        "domain_expiration_days_left": "123"
    },
    "similar_domains": [
        "bestbuy.com",
        "icloud.com",
        "microsoft.com",
        "macrumors.com",
        "google.com",
        "samsung.com",
        "twitter.com",
        "hp.com",
        "bhphotovideo.com",
        "dell.com"
    ]
}

Key fields you’ll typically use:

  • domain.categories: a list of categories with confidence, including an IAB code mapping on some entries for ad-tech pipelines.
  • domain.logo_url: a public URL for the company logo you can store or render in dashboards.
  • objects.company: normalized company details (name, location, employeesRange, revenue, tags, tech) for CRM enrichment.
  • domain_registration_data: timestamps and counters for domain age and expiration to inform trust and prioritization decisions.
  • similar_domains: related domains you can use for suggestions, lookalike modeling, or competitive research.

For social profile enrichment, pair these fields with your call to the Social Profiles endpoint. If domain.social_media is null in categorization data, still run the Social Profiles endpoint to get per-platform URLs or nulls.

How to fit results into your pipeline

Normalization and storage

  • Key by registrable root: Normalize domains to example.com-level before storage to avoid duplication across www, m.example.com, and country subdomains.
  • Null-safe schema: Store each platform as a nullable text field. Upserts should preserve nulls when reprocessing to avoid reintroducing stale links.
  • Versioned enrichment: Track the retrieval timestamp and source (“klazify-social”) as metadata for troubleshooting.

Caching and TTLs

  • Cache per registrable root for 7–30 days depending on your data freshness needs. Many organizations align TTLs with their internal recrawl cadence.
  • Invalidate on domain content changes: If your crawler detects significant homepage changes or a CMS redesign, refresh the profiles early.
  • Cache misses: When all platforms are null, schedule a lighter retry after a longer delay to reduce churn.

Batching and rate limits

  • Batch by queue: Drain domains from your ingestion queue in small, controlled bursts with concurrency limits (e.g., 5–20 parallel workers) to respect rate limits.
  • Backoff: On sustained non-2xx responses or transport issues, back off exponentially and retry with jitter.
  • Idempotency: Deduplicate queued domains by root and last-seen timestamp to avoid redundant hits.

Error handling and unknown domains

  • Transport errors: Not billed when unreachable. Log, retry with backoff, and surface metrics.
  • New or sparse sites: Expect nulls if the domain does not publish social links. Recheck on your next crawl window.
  • Canonicals and redirects: Always follow HTTP redirects for the URL you enrich and store the canonical domain to prevent drift.

Mapping profiles and categories to your taxonomy

Many teams blend profile resolution with content classification and then map the results into their internal categories or risk tiers. Here’s a simple approach:

  • Maintain a platform map: facebook → social.facebook, x → social.x, etc., in your internal schema.
  • Use categories to gate workflows: e.g., only request creative partnerships if the domain is in an allowed IAB group.
  • Store IAB codes directly alongside your internal codes to support auditability and re-mapping without reprocessing raw text.
Signal Field source How to use Action if missing
Facebook URL Social Profiles endpoint Link company pages; route social listening Leave null; retry on site changes
X URL Social Profiles endpoint Ad ops verification; brand safety checks Leave null; schedule periodic refresh
LinkedIn URL Social Profiles endpoint CRM/company matching Fallback to company name search offline
IAB category domain.categories Brand safety and contextual targeting Flag for manual review or broad category
Logo URL domain.logo_url UI display and CRM profile cards Use initials or house default logo

Testing checklist

  • Happy path: Domains with multiple public profiles; verify non-null fields match official pages.
  • Edge domains: Newly registered sites and static landing pages; expect more nulls.
  • Internationalized domains: Confirm normalization and storage layer handle Unicode safely.
  • Redirects and www vs root: Confirm identical results are deduplicated.
  • Resilience: Simulate timeouts and non-2xx responses; validate that retries work and no duplicate writes occur.

Account, pricing, and where to go next

You can start with the Starter plan at $39.99/month with a 7-day trial. Failed or unreachable calls are not billed. Create your API key and follow the docs:

  • Register to get your API key and start your trial.
  • Review the Documentation for endpoints and field references.
  • Explore MCP for management and configuration.

Frequently asked questions

What happens if a platform field is missing?
It will be null. Treat null as “no profile found” and avoid guessing. Retrying later is safe if you suspect the site was updated.

Can I enrich social profiles and categories in one call?
Use the Social Profiles endpoint for profiles and the main categorization endpoint for categories and company details. Many teams call both as part of a single enrichment job.

How should I cache results?
Cache per registrable root (e.g., example.com) for 7–30 days, store the retrieval timestamp, and invalidate early when your crawler detects significant homepage changes.

How do I handle rate limits?
Use small, steady batches with controlled concurrency and exponential backoff on non-2xx responses. Queue deduplication prevents wasteful retries.

Are unsuccessful calls billed?
Failed or unreachable calls are not billed, so you can retry safely after backoff.

Ready to enrich domains with verified social profiles and plug the results directly into your CRM, ad safety, or analytics workflows? Create your API key and start your 7-day trial here: Register. For implementation details and field references, bookmark the Documentation.

Ready to use Klazify?

Start classifying websites, enriching company data, and exploring web intelligence.

Get Started Free