playing nice with others

14
Playing Nice with Others Integrating WordPress with External APIs Eric Mann @ericmann http://about.me/eam WordCamp Phoenix February 26, 2012

Upload: eric-mann

Post on 08-Apr-2017

1.437 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Playing nice with others

Playing Nice with OthersIntegrating WordPress with External APIs

Eric Mann @ericmann http://about.me/eamWordCamp Phoenix February 26, 2012

Page 2: Playing nice with others

Integrating WordPress with External APIs

• Background• Technologies in use• Available tools• Practical Examples• Questions

Page 3: Playing nice with others

BACKGROUND

Page 4: Playing nice with others

TECHNOLOGIES

Page 5: Playing nice with others

ReST

Page 6: Playing nice with others

XML-RPC

Page 7: Playing nice with others

JSON

Page 8: Playing nice with others

TOOLS

Page 9: Playing nice with others

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 );

Page 10: Playing nice with others

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!';

}

Page 11: Playing nice with others

EXAMPLES

Page 12: Playing nice with others

Twitter - ReST

GET http://search.twitter.com/search.json?q=%23wcphx&rpp=5&include_entities=false&result_type=recent

Page 13: Playing nice with others

Extending XMLRPC

add_filter( 'xmlrpc_methods', 'wcphx_add_method' );

Page 14: Playing nice with others

QUESTIONS?