Resource Information
Method | POST |
---|---|
URL | https://public-api.wordpress.com/rest/v1.1/sites/$site/publicize-connections/new |
Requires authentication? | Yes |
Method Parameters
Parameter | Type | Description |
---|---|---|
$site | (int|string) | Site ID or domain. |
Query Parameters
Parameter | Type | Description |
---|---|---|
context | (string) |
|
http_envelope | (bool) |
|
pretty | (bool) |
|
meta | (string) | Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes |
fields | (string) | Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title |
callback | (string) | An optional JSONP callback function. |
Request Parameters
Parameter | Type | Description |
---|---|---|
keyring_connection_ID | (int) | The Keyring connection ID to use for the new publicize connection. |
shared | (bool) | Optional. True to make the connection global for all users of the site. |
external_user_ID | (string) | Optional. Use to associate a non-default external user (from the Keyring connection) with this publicize connection. e.g. associate a Facebook page. |
Response Parameters
Parameter | Type | Description |
---|---|---|
ID | (int) | The ID of the publicize connection. |
site_ID | (int) | The site ID that the publicize connection belongs to. |
user_ID | (int) | The user ID that the publicize connection belongs to. |
shared | (bool) | Is this connection shared? |
keyring_connection_ID | (int) | The ID of the associated Keyring connection. |
keyring_connection_user_ID | (int) | The ID of the user who owns the associated keyring connection. |
service | (string) | The name of the service associated with this publicize connection. |
label | (string) | The display friendly name of the service associated with this publicize connection. |
issued | (iso 8601 datetime) | Date when the publicize connection was first established. |
expires | (iso 8601 datetime) | Date when the publicize connection expires, if any. |
external_ID | (string) | An identifier for the user on the third-party service. |
external_name | (string) | A display friendly identifier for the user on the third-party service, usually a username or login name. |
external_display | (string|null) | A display friendly identifier for the user on the third-party service, typically defined by the user and the one that the user has chosen as their preferred identifier. |
external_profile_picture | (url|null) | The URL to the profile picture associated with the third-party account, if the service provides one. |
external_profile_URL | (url|null) | The URL to the external profile on the third-party website, if the service provides one. |
external_follower_count | (int|null) | The number of followers that the user has on the third-party service, if the service returns a number. |
URL | (string|null) | URL to the user's profile on the third-party service. NULL if there is no URL to link to. |
status | (string) | The current status of the connection to the third-party service. "ok" for connections with no problems, and "broken" for connections that need to be fixed fixed. |
refresh_URL | (url) | The URL to refresh the Keyring token. |
meta | (object) | Object with links to the publicize connection, help links and related items. |
Resource Errors
These are the possible errors returned by this endpoint.
HTTP Code | Error Identifier | Error Message |
---|---|---|
403 | unauthorized | User cannot access this private blog. |
403 | unauthorized | User cannot access this restricted blog |
Example
curl \ -H 'authorization: Bearer YOUR_API_TOKEN' \ --data-urlencode 'keyring_connection_ID=1234' \ 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.com/publicize-connections/new'
<?php $options = array ( 'http' => array ( 'ignore_errors' => true, 'method' => 'POST', 'header' => array ( 0 => 'authorization: Bearer YOUR_API_TOKEN', 1 => 'Content-Type: application/x-www-form-urlencoded', ), 'content' => http_build_query( array ( 'keyring_connection_ID' => 1234, )), ), ); $context = stream_context_create( $options ); $response = file_get_contents( 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.com/publicize-connections/new', false, $context ); $response = json_decode( $response ); ?>
Response
{ "ID": 1234567, "site_ID": 3584907, "user_ID": 12345678, "keyring_connection_ID": 1234567, "keyring_connection_user_ID": 12345678, "shared": false, "service": "twitter", "label": "Twitter", "issued": "2014-08-2302:49:47", "expires": "0000-00-0000:00:00", "external_ID": "15919116", "external_name": "Automattic", "external_display": "@automattic", "external_profile_picture": "https:\/\/pbs.twimg.com\/profile_images\/453860857923923968\/Rg_FuLjK_400x400.png", "external_profile_URL": "http:\/\/twitter.com\/automattic", "external_follower_count": 24103, "status": "ok", "refresh_URL": "https:\/\/public-api.wordpress.com\/connect\/?action=request&kr_nonce=xxxxxxxxxx&nonce=xxxxxxxxxx&refresh=1&for=connect&service=twitter&kr_blog_nonce=xxxxxxxxxx&magic=keyring&blog=3584907", "meta": { "links": { "self": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/publicize-connections\/1234567", "help": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/publicize-connections\/1234567\/help", "site": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907", "service": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/meta\/external-services\/twitter", "keyring-connection": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/me\/keyring-connections\/1234567" } } }