Skip to main content

Ìtọ́kasí REST API

Ìṣètò Ìpìlẹ̀

URL Ìpìlẹ̀: {site_url}/wp-json/wu/v2/ Ìjẹ́rìísí: Bọtini API & Aṣírí (HTTP Basic Auth tàbí Parameters URL)

Ìjẹ́rìísí

Mú API ṣiṣẹ́

// Enable API in Ultimate Multisite settings or programmatically
wu_save_setting('enable_api', true);

Gba Àwọn Ẹ̀rí API

$api_key = wu_get_setting('api_key');
$api_secret = wu_get_setting('api_secret');

Àwọn Ọ̀nà Ìjẹ́rìísí

HTTP Basic Auth (A ṣe àbá):

curl -u "api_key:api_secret" https://yoursite.com/wp-json/wu/v2/customers

Parameters URL:

curl "https://yoursite.com/wp-json/wu/v2/customers?api_key=your_key&api_secret=your_secret"

Àwọn Ojuami Ìparí Pàtàkì

1. API Àwọn Oníbàárà

Ọ̀nà Ìpìlẹ̀: /customers

Gba Gbogbo Àwọn Oníbàárà

GET /wu/v2/customers

Gba Oníbàárà Kan Ṣoṣo

GET /wu/v2/customers/{id}

Ṣẹ̀dá Oníbàárà

POST /wu/v2/customers
Content-Type: application/json

{
"user_id": 123,
"email_verification": "verified",
"type": "customer",
"has_trialed": false,
"vip": false
}

Ṣe Àfikún Oníbàárà

PUT /wu/v2/customers/{id}
Content-Type: application/json

{
"vip": true,
"extra_information": "VIP customer notes"
}

Pa Oníbàárà Rẹ́

DELETE /wu/v2/customers/{id}

2. API Àwọn Ojúlé

Ọ̀nà Ìpìlẹ̀: /sites

Ṣẹ̀dá Ojúlé

POST /wu/v2/sites
Content-Type: application/json

{
"customer_id": 5,
"membership_id": 10,
"domain": "example.com",
"path": "/",
"title": "My New Site",
"template_id": 1,
"type": "customer_owned"
}

3. API Àwọn Ọmọ ẹgbẹ́

Ọ̀nà Ìpìlẹ̀: /memberships

Ṣẹ̀dá Ọmọ ẹgbẹ́

POST /wu/v2/memberships
Content-Type: application/json

{
"customer_id": 5,
"plan_id": 3,
"status": "active",
"gateway": "stripe",
"gateway_subscription_id": "sub_1234567890",
"auto_renew": true
}

4. API Àwọn Ọjà

Ọ̀nà Ìpìlẹ̀: /products

Gba Gbogbo Àwọn Ọjà

GET /wu/v2/products

5. API Àwọn Ìsanwó

Ọ̀nà Ìpìlẹ̀: /payments

Ṣẹ̀dá Ìsanwó

POST /wu/v2/payments
Content-Type: application/json

{
"customer_id": 5,
"membership_id": 10,
"status": "completed",
"gateway": "stripe",
"gateway_payment_id": "pi_1234567890",
"total": 29.99,
"currency": "USD"
}

6. API Àwọn Domain

Ọ̀nà Ìpìlẹ̀: /domains

So Domain pọ̀

POST /wu/v2/domains
Content-Type: application/json

{
"domain": "custom-domain.com",
"customer_id": 5,
"primary_domain": 1,
"stage": "domain-mapping"
}

Ojuami Ìparí Ìforúkọsílẹ̀

Ojuami ìparí /register ń pèsè checkout/ìforúkọsílẹ̀ tó pé:

POST /wu/v2/register
Content-Type: application/json

{
"customer": {
"username": "newuser",
"password": "securepass123",
"email": "[email protected]"
},
"products": ["basic-plan"],
"duration": 1,
"duration_unit": "month",
"auto_renew": true,
"site": {
"site_url": "mynewsite",
"site_title": "My New Site",
"template_id": 1
},
"payment": {
"status": "completed"
},
"membership": {
"status": "active"
}
}

Ìdáhùn:

{
"customer": { ... },
"membership": { ... },
"payment": { ... },
"site": { "id": 123 }
}

Àwọn Ojuami Ìparí Ayálégbé Aláṣẹ-ara

Ultimate Multisite: Ọ̀pọ̀-Ayálégbé 1.2.0 ṣàfikún ìbòjúmu REST fún ayálégbé aláṣẹ-ara fún àwọn ìṣepọ̀ tó ń pèsè, ṣàyẹ̀wò, tàbí jẹ́rìí sí àwọn ayálégbé tí a yà sọ́tọ̀.

Ẹrù ìbéèrè gangan dá lórí agbára host tí a ti mú ṣiṣẹ́, ṣùgbọ́n àwọn ìṣepọ̀ gbọ́dọ̀ retí àwọn ẹgbẹ́ ojuami ìparí wọ̀nyí:

POST /wu/v2/tenants/{site_id}/bootstrap
GET /wu/v2/tenants/{site_id}/migration-status
POST /wu/v2/tenants/{site_id}/verify
DELETE /wu/v2/tenants/{site_id}

Lo ojuami ìparí bootstrap láti pèsè ìforúkọsílẹ̀ ayálégbé, database, filesystem, àti ipò routing. Lo àwọn ojuami ìparí ipò ìṣílọ àti ìjẹ́rìísí kí o tó yí traffic production padà. Lo ojuami ìparí ìparẹ́ fún ìtúká aláṣẹ-ara kí a lè yọ àwọn ẹ̀rí database kúrò nípasẹ̀ ìṣàn ìmúmọ́ addon.

Àwọn ìdáhùn ipò ìṣílọ aṣojúṣe maa ń ní:

{
"site_id": 123,
"isolation_model": "sovereign",
"database_host": "localhost",
"verification": {
"no_legacy": "passed",
"sovereign_push": "passed",
"tenant_users": "passed"
},
"ready": true
}

Ka ready: false sí ohun ìdènà ṣáájú ìfilọlẹ̀. Ṣàyẹ̀wò àwọn àlàyé ìjẹ́rìísí, tún ìsopọ̀ host database, queue, ìpèsè oníṣe, tàbí ìṣòro routing ṣe, lẹ́yìn náà tún ìjẹ́rìísí gbìyànjú.

Àwọn Ìdáhùn Àṣìṣe

{
"code": "wu_rest_invalid_parameter",
"message": "Invalid parameter value",
"data": {
"status": 400,
"params": {
"email": "Invalid email format"
}
}
}

Ìpín sí Ojú-ìwé àti Ìyàn

Parameters Ìbéèrè:

GET /wu/v2/customers?per_page=20&page=2&search=john&status=active

Àwọn parameters tó wọ́pọ̀:

  • per_page - Àwọn ohun kan fún ojú-ìwé kọ̀ọ̀kan (àiyipada: 20, pọ̀jù: 100)
  • page - Nọ́mbà ojú-ìwé
  • search - Ọ̀rọ̀ ìṣàwárí
  • orderby - Pápá ìtòlẹ́sẹẹsẹ
  • order - Ìtọ́sọ́nà ìtòlẹ́sẹẹsẹ (asc/desc)
  • status - Yàn gẹ́gẹ́ bí ipò
  • date_created - Yàn gẹ́gẹ́ bí ààlà ọjọ́