https://github.com/webdevstudios/wp_addthis_api_connect
Connect to the Addthis API using WordPress APIs
https://github.com/webdevstudios/wp_addthis_api_connect
Last synced: 8 months ago
JSON representation
Connect to the Addthis API using WordPress APIs
- Host: GitHub
- URL: https://github.com/webdevstudios/wp_addthis_api_connect
- Owner: WebDevStudios
- Created: 2014-07-18T13:35:49.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-08-07T13:59:30.000Z (over 11 years ago)
- Last Synced: 2025-03-27T13:45:11.196Z (about 1 year ago)
- Language: PHP
- Size: 160 KB
- Stars: 7
- Watchers: 11
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
WP Addthis API Connect
======================
Connect to the [Addthis API](http://support.addthis.com/customer/portal/articles/381262-api-and-sdk-overview) using WordPress APIs
To get started, create a new WP_Addthis_API_Connect object by passing your username, password, pubid, and url (registered with Addthis).
```php
// Consumer credentials
$credentials = array(
'username' => 'justin@webdevstudios.com',
'password' => 'XXXXXXXXXXX',
'pubid' => 'ra-XXXXXXXXXXX',
'url' => 'webdevstudios.com',
);
$api = new WP_Addthis_API_Connect( $credentials );
```
You can then use this object to retrieve the authentication request URL, or if you have been authenticated, make requests.
```php
'justin@webdevstudios.com',
'password' => 'XXXXXXXXXXX',
'pubid' => 'ra-XXXXXXXXXXX',
'url' => 'webdevstudios.com',
);
$api = new WP_Addthis_API_Connect( $credentials );
$args = array(
'service' => 'twitter',
'domain' => 'webdevstudios.com',
'period' => 'last24',
'url' => 'http://webdevstudios.com/post-to-check',
);
// Get all twitter shares split into counts for every 10 minute increment
// in the last 24 hours.
$shares = $api->get_shares( 'url.json', $args );
if ( is_wp_error( $shares ) ) {
echo '
';
echo wpautop( $shares->get_error_message() );
echo '';
} else {
$shares_count = 0;
foreach ( $shares as $share ) {
$shares_count = $shares_count + absint( $share->shares );
}
echo '
';
echo '
$shares_count: '. print_r( $shares_count, true ) .'';
echo '$shares: '. print_r( $shares, true ) .'';
echo '';
}
}
add_action( 'all_admin_notices', 'wp_addthis_api_connect_example_test' );
```