FACEBOOK_GROUP_PUBLISH_LINK::process_action( $user_id,  $action_data,  $recipe_id,  $args,  $parsed )

Proccess our action.


Return Return

(Uncanny_Automatorvoid.)


Source Source

File: src/integrations/facebook-groups/actions/facebook-group-publish-link.php

	public function process_action( $user_id, $action_data, $recipe_id, $args, $parsed ) {

		$helper = Automator()->helpers->recipe->facebook_groups->options;

		// Group ID.
		$group_id = isset( $parsed[ $this->get_action_meta() ] ) ? sanitize_text_field( $parsed[ $this->get_action_meta() ] ) : 0;

		// Message.
		$message = isset( $parsed['FACEBOOK_GROUPS_PUBLISH_LINK_MESSAGE'] ) ? sanitize_textarea_field( $parsed['FACEBOOK_GROUPS_PUBLISH_LINK_MESSAGE'] ) : '';

		// Link.
		$link = isset( $parsed['FACEBOOK_GROUPS_PUBLISH_LINK_URL'] ) ? sanitize_text_field( $parsed['FACEBOOK_GROUPS_PUBLISH_LINK_URL'] ) : '';

		$body = array(
			'access_token' => $helper->get_user_access_token(),
			'message'      => $message,
			'link'         => $link,
			'action'       => 'send_link',
			'group_id'     => $group_id,
		);

		try {

			$helper->api_request( $body, $action_data );

			Automator()->complete->action( $user_id, $action_data, $recipe_id );

		} catch ( \Exception $e ) {

			$action_data['complete_with_errors'] = true;

			// Log error if there are any error messages.
			Automator()->complete->action( $user_id, $action_data, $recipe_id, $e->getMessage() );
		}

	}