How to Get a Company's Social Profiles in PHP
You’re enriching signups and vendor records with verified social profiles so sales and brand teams don’t hunt them down manually. By the end of this guide, you’ll call a single API to get a company’s Facebook, X, Instagram, YouTube, LinkedIn, GitHub, Pinterest, and Medium URLs, handle nulls when profiles don’t exist, cache the results per domain, and plug everything into your pipeline.
Why Klazify is the right API for extracting company social profiles at scale
When your downstream workflows depend on complete, accurate social URLs, “almost correct” links create churn for SDRs, product features, and analytics. Klazify pairs social media URL detection with robust website classification so you can both extract profiles reliably and add business context when needed.
- Accurate website categorization using AI: Klazify analyzes full-site content, not just metadata. That means the same crawl that finds social URLs also reveals what the site is actually about, letting you decide when to enrich, block, or flag a domain by category.
- Global coverage: Companies publish social links in multiple languages and formats. Klazify’s domain analysis handles international sites, improving hit rates beyond simple pattern scraping.
- Real-time classification: Use up-to-date signals from a fresh analysis rather than stale databases. If a company adds a YouTube channel tomorrow, you can pick it up without waiting for bulk list updates.
- Industry-level categories (IAB): Map domains to IAB taxonomy when you need to pair social discovery with brand safety, ad targeting, or policy decisions.
- Simple API integration: A single REST call returns social links per domain. Add classification data from the categorize endpoint to power nuanced rules.
- Compliance and filtering: Combine profile extraction with IAB categories to block or whitelist domains by policy and ensure only allowed profiles make it into your CRM or ad systems.
If you need to roll this into production with meaningful SLAs, you’ll appreciate how the social endpoint and categorization complement each other and how easy it is to cache results by domain.
Endpoints you’ll call
You will use one primary endpoint for social profile extraction, and optionally the categorization endpoint for enrichment and business logic.
- POST https://www.klazify.com/api/domain_social_media
- Authorization: Bearer YOUR_API_KEY
- Body: JSON with a single key “url”
- Returns: Detected social profiles across Facebook, X, Instagram, YouTube, LinkedIn, GitHub, Pinterest, and Medium. If a profile doesn’t exist or can’t be verified, its value is null.
- POST https://www.klazify.com/api/categorize
- Purpose: Website classification and content categorization
- Use this to add IAB categories, logo URL, and company info next to the social links you store.
You can explore both endpoints and schema details in the Documentation and MCP. To try it now, create a free account: Register.
Quickstart: one curl to get social profiles
This request sends a domain and returns its official social URLs. Missing profiles are null, so your code can safely branch on presence.
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:
- Use HTTPS and include the Authorization header as shown.
- Send a full URL or bare domain; Klazify normalizes it.
- Only reachable, successful calls are counted; failed or unreachable calls are not billed.
Implement it in PHP and JavaScript
PHP: cURL-based POST with null-safe extraction
<?php
$apiKey = "YOUR_API_KEY";
$endpoint = "https://www.klazify.com/api/domain_social_media";
$payload = json_encode([
"url" => "https://example.com"
]);
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {$apiKey}",
"Content-Type: application/json",
"Accept: application/json"
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($response === false) {
error_log("Klazify request failed: " . curl_error($ch));
curl_close($ch);
http_response_code(502);
exit;
}
curl_close($ch);
if ($httpCode < 200 || $httpCode >= 300) {
// Not billed for failed or unreachable calls; decide whether to retry
error_log("Klazify non-2xx response: HTTP {$httpCode} - {$response}");
http_response_code(502);
exit;
}
$data = json_decode($response, true);
// Each profile is either a URL string or null
$profiles = [
'facebook' => $data['facebook'] ?? null,
'x' => $data['x'] ?? null,
'instagram' => $data['instagram'] ?? null,
'youtube' => $data['youtube'] ?? null,
'linkedin' => $data['linkedin'] ?? null,
'github' => $data['github'] ?? null,
'pinterest' => $data['pinterest'] ?? null,
'medium' => $data['medium'] ?? null,
];
// Example: upsert only non-null profiles to your DB
foreach ($profiles as $network => $url) {
if (!empty($url)) {
// Save or update {$network}_url column for the company record
}
}
// Example response to your client
header("Content-Type: application/json");
echo json_encode([
"domain" => "example.com",
"profiles" => $profiles
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
JavaScript (Node.js): fetch and fan-in to your pipeline
import fetch from "node-fetch";
async function getSocialProfiles(domainUrl) {
const res = await fetch("https://www.klazify.com/api/domain_social_media", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({ url: domainUrl }),
// Optionally add a timeout controller in production
});
if (!res.ok) {
// Failed or unreachable calls are not billed; consider retry/backoff
const text = await res.text();
throw new Error(`Klazify error ${res.status}: ${text}`);
}
const data = await res.json();
// Null-safe extraction: a missing profile will be null
const {
facebook = null,
x = null,
instagram = null,
youtube = null,
linkedin = null,
github = null,
pinterest = null,
medium = null
} = data;
return {
domain: domainUrl,
profiles: { facebook, x, instagram, youtube, linkedin, github, pinterest, medium }
};
}
// Example usage
getSocialProfiles("https://example.com")
.then(result => {
console.log("Profiles:", result.profiles);
// Upsert to CRM or enrich signup here
})
.catch(err => {
console.error(err.message);
});
Store a null to indicate “known missing” so you can avoid re-querying the same domain during the cache TTL. When a profile later appears, refresh the cache and update your record.
What the categorization endpoint adds to your enrichment
Alongside social URLs, many teams want company and category context for routing or brand safety. The categorize endpoint returns IAB categories, a logo URL, and company fields. Here is the official example response (use it as your reference for fields and shapes):
{
"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"
]
}
How to use key fields:
- domain.categories: Apply IAB mapping to enforce category-based rules when importing social profiles into ad systems or CRMs. The confidence helps decide thresholds.
- domain.logo_url: Store a logo next to social links for cleaner UI in admin tools and CRM widgets.
- objects.company.*: Use name, location, employeesRange, revenue, tags, and tech to route accounts to the right team or segment.
- domain_registration_data: Helps qualify domains that look newly created or near expiration when assessing risk.
- similar_domains: Build a completion task list to fetch social profiles for related properties.
Even if you only need social URLs today, keeping category and company context available gives you options for compliance checks and smarter enrichment down the road. Visit https://www.klazify.com to see how the same dataset powers multiple workflows.
What the social profile response means for your code
The social endpoint returns up to eight keys corresponding to platforms. Each is either a URL string (verified official profile) or null if unknown or not present.
| Field | Type | Behavior | Common Action |
|---|---|---|---|
| string | null | Company Facebook Page URL or null | Store in facebook_url column; show badge in UI | |
| x | string | null | Company X (Twitter) profile URL or null | Store in x_url; enable follow links |
| string | null | Instagram business profile URL or null | Display gallery actions; track social reach | |
| youtube | string | null | YouTube channel URL or null | Embed channel; manage video content workflows |
| string | null | LinkedIn company page URL or null | Enrich B2B accounts in CRM | |
| github | string | null | GitHub organization URL or null | Surface OSS signals for dev tooling |
| string | null | Pinterest profile URL or null | Merchandising insights for retailers | |
| medium | string | null | Medium publication URL or null | Content marketing visibility |
Design your schema to accept nulls and avoid “missing vs unknown” ambiguity. For example, keep a last_checked_at timestamp per domain so you can schedule periodic refreshes and reconcile changes.
End-to-end workflow: from POST to your DB
- Normalize input:
- Accept user-submitted URLs (with or without protocol). Normalize to a canonical domain for caching, e.g., example.com.
- Check cache:
- If you have a recent, non-expired record, use it immediately. Cache keys can be the normalized domain.
- Call domain_social_media:
- Send the input URL; on HTTP 2xx, parse the eight social fields.
- If the response is a network error or non-2xx, log and retry based on your backoff policy. Remember failed or unreachable calls are not billed.
- Upsert results:
- Persist each platform URL if not null. Persist nulls explicitly with a checked timestamp to prevent redundant calls until the next refresh cycle.
- Optional enrichment with categorize:
- Fetch categories and objects.company fields and store alongside the social profiles for scoring, routing, and UI context.
Batching, rate limits, and resilience in production
- Batching: Group domains logically (e.g., signup backlog, nightly CRM updates) and parallelize within your allowed rate limits. If you queue jobs, use a concurrency setting so you don’t exceed limits.
- Retry policy: Use exponential backoff on transient network errors. Because failed or unreachable calls are not billed, safe retry with jitter is reasonable.
- Caching: Cache per domain for a TTL that matches your freshness needs. For high-churn brands, reduce TTL. For stable B2B vendors, extend TTL to cut latency and cost.
- Idempotency: Store a request fingerprint (domain + purpose) so retries don’t create duplicates downstream.
- Null handling: Null means “not available/verified now.” Respect it and re-check only on schedule, not every request.
- Monitoring: Track hit rate by platform, error codes, and average latency per batch. Alert if nulls spike for a given platform, which may indicate upstream changes on the site.
Handling unknown or new domains
New domains may lack social presence. Your options:
- Save nulls with a short TTL (e.g., hours or days) and auto-retry later.
- If categorization shows a relevant IAB vertical, route the account for manual verification even when links are null.
- Use similar_domains from categorize to discover sibling sites that may publish social links first.
Mapping to your own taxonomy and systems
The social profile fields are straightforward to map into typical schemas:
- CRM: facebook_url, x_url, instagram_url, youtube_url, linkedin_url, github_url, pinterest_url, medium_url
- Data warehouse: a nested JSON column or a wide table with nullable columns for each platform
- Analytics: a boolean has_social flag derived from any non-null profile, plus per-platform booleans
When you also use categorize, map domain.categories to your internal category list. If you already use IAB, you can directly store the category path string and confidence. If you use another taxonomy, a simple lookup table from IAB paths to your categories covers most needs.
Operational details that save time
- Authentication: Use the Bearer token as shown. Rotate keys via your secrets manager and deploy without code changes.
- Timeouts: Set client timeouts (e.g., 20–30s) and lower them in synchronous UX flows. Use async workers for bulk enrichment.
- Storage: Keep a last_seen_url per platform so you can detect changes and notify downstream systems.
- Auditing: Log the domain, platform, and URL each time a profile changes from null to a value or vice versa.
- Pricing: The Starter plan is $39.99/mo with a 7-day trial. Failed or unreachable calls are not billed.
If you need to scale beyond a single microservice, place the Klazify integration behind an internal API and control concurrency centrally. Learn more at https://www.klazify.com.
How to use the returned fields in real workflows
- Signup enrichment: After a domain is submitted, call domain_social_media and upsert non-null profiles. If linkedin is present, route to an enterprise SDR queue; if github is present, surface developer-oriented onboarding.
- Brand safety and ad ops: Use categorize to check IAB category before syncing social profiles into campaign allowlists. Only export profiles if categories meet your policy threshold.
- Cybersecurity and risk: For vendors, require linkedin and youtube to be present, or treat absent profiles (nulls) as a soft risk signal that triggers manual review.
- Analytics: Track adoption by platform. A rising share of youtube or medium profiles among your accounts may inform content partnerships.
Testing and validation
- Unit tests: Mock the social endpoint and assert that nulls do not overwrite existing non-null URLs unless they age out.
- Schema migrations: Add nullable columns first. Backfill from a job that re-queries domains and populates profiles.
- QA: Create fixtures with all-null, single-platform, and multi-platform responses to verify UI rendering and downstream exports.
FAQ
- What happens if a company has no social profiles?
The endpoint returns null for each missing platform. Store the nulls with a timestamp and re-check on your own refresh schedule. - Do redirects or vanity URLs break detection?
No. Provide the canonical domain URL; Klazify normalizes and analyzes the site to detect official profiles. - Can I enrich with categories and company data alongside social links?
Yes. Call the categorize endpoint to get IAB categories, logo_url, and company fields, then store them with the social URLs. - How should I handle rate limits?
Use a queue with controlled concurrency and exponential backoff. Cache per domain to minimize repeated calls. - Are failed or unreachable calls billed?
No. Failed or unreachable calls are not billed.
Ready to enrich your product with verified social profiles and category context? Create your free account and start building in minutes: Register. For full reference, see the Documentation and explore models in MCP.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free