https://github.com/mithro/googleplus2wordpress
Import data from Google+ to Wordpress
https://github.com/mithro/googleplus2wordpress
Last synced: about 1 year ago
JSON representation
Import data from Google+ to Wordpress
- Host: GitHub
- URL: https://github.com/mithro/googleplus2wordpress
- Owner: mithro
- License: apache-2.0
- Created: 2012-05-28T08:00:23.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2014-04-22T04:36:08.000Z (about 12 years ago)
- Last Synced: 2025-04-04T22:45:56.739Z (about 1 year ago)
- Language: Python
- Size: 254 KB
- Stars: 2
- Watchers: 2
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Import data from Google+ to Wordpress
-------------------------------------------------------------------------------
Will eventually sync both posts and comments on the posts.
Uses the Google+ Public API, so can only sync public posts. Uses it via the
google-api-python-client python module.
Uses the Wordpress XMLRPC API, so that needs to be enabled. Uses it via the
python-wordpress-xmlrpc python module.
html2text and nltk are used for generating a much nicer title then G+ produces.
(By getting the first sentance.)
oEmbed is used to get some nice extra information about the stuff we are trying
to embed, because G+ is really crappy at passing useful info. (We also use my
custom Picasa Web oEmbed endpoint to do video embedding).
We produce a bunch of different post types to allow styling different;
* Standard Text Post
* Single Photo/Video post
* Gallery Post (collection of Photo/Videoes)
* http://highslide.com
* Website share
There is also a "reshare" post which is basically one of the above post types
wrapped in a reshare block tell who it came from.
# Set Up
Install requirements in requirements.txt
$ sudo pip install -r requirements.txt
Create a config.py with your Embedly key;
$ cp config.py.dist config.py
Create a client_secrets.json with your G+ API key details;
$ cp client_secrets.json.dist client_secrets.json
Run the command
$ python plus.py
Wordpress Side
-------------------------------------------------------------------------------
*** Warning PHP code! ***
Stores the G+ ids in the Wordpress Meta information -
'meta_query' => array(
array(
'key' => 'google_plus_(activity|comment)_id',
'value' => XXXX,
),
We use the following Wordpress filter, to support showing Google+ photos in the
comments; this basically stores the URL in the meta data under 'google_plus_comment_avatar'.
function get_avatar_google($avatar, $id_or_email, $size, $default, $alt) {
if (isset($id_or_email->comment_ID)) {
$plus_avatar = get_comment_meta($id_or_email->comment_ID, 'google_plus_comment_avatar', true);
$matches = array();
if (preg_match('/(https:\/\/.*\.googleusercontent\.com.*)\?sz=\d+/', $plus_avatar, $matches)) {
return "
";
}
}
return $avatar;
}
add_filter( 'get_avatar', 'get_avatar_google', 1, 5);