Upload
eric-mann
View
1.437
Download
0
Embed Size (px)
Citation preview
Playing Nice with OthersIntegrating WordPress with External APIs
Eric Mann @ericmann http://about.me/eamWordCamp Phoenix February 26, 2012
Integrating WordPress with External APIs
• Background• Technologies in use• Available tools• Practical Examples• Questions
BACKGROUND
TECHNOLOGIES
ReST
XML-RPC
JSON
TOOLS
WP_Httpwp_remote_post( $url, $args );wp_remote_get( $url, $args );wp_remote_head( $url, $args );wp_remote_request( $url, $args );
wp_remote_retrieve_body( $response );wp_remote_retrieve_header( $response, $header );wp_remote_retrieve_headers( $response );wp_remote_retrieve_response_code( $response );wp_remote_retrieve_response_message( $response );
wp_xmlrpc_serveradd_filter( 'xmlrpc_methods', 'wcphx_add_method' );
function wcphx_add_method( $methods ) {$methods['wcphx.sayHello'] =
'wcphx_sayHello';return $methods;
}
function wcphx_sayHello( $args ) {return 'Hello!';
}
EXAMPLES
Twitter - ReST
GET http://search.twitter.com/search.json?q=%23wcphx&rpp=5&include_entities=false&result_type=recent
Extending XMLRPC
add_filter( 'xmlrpc_methods', 'wcphx_add_method' );
QUESTIONS?