TWITTER_POSTSTATUS::post_status( $user_id, $action_data, $recipe_id, $args )
Action validation function.
Return Return
(mixed)
Source Source
File: src/integrations/twitter/actions/twitter-poststatus.php
public function post_status( $user_id, $action_data, $recipe_id, $args ) { $status = Automator()->parse->text( $action_data['meta']['TWITTERSTATUSCONTENT'], $recipe_id, $user_id, $args ); try { $response = $this->statuses_update( $status ); if ( is_array( $response ) && ! is_wp_error( $response ) ) { $body = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! isset( $body->errors ) ) { Automator()->complete_action( $user_id, $action_data, $recipe_id ); return; } else { foreach ( $body->errors as $error ) { $error_msg .= $error->code . ': ' . $error->message . PHP_EOL; } $action_data['do-nothing'] = true; $action_data['complete_with_errors'] = true; Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_msg ); return; } } else { throw new \Exception( __( 'WordPress was unable to communicate with the Automator API.', 'uncanny-automator' ) ); } } catch ( \Exception $e ) { $error_msg = $e->getMessage(); $action_data['do-nothing'] = true; $action_data['complete_with_errors'] = true; Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_msg ); return; } }
Expand full source code Collapse full source code View on Github