TWITTER_POSTSTATUS_2::statuses_update( string $status,  $media_id = '' )

Send data to Automator API.


Parameters Parameters

$status

(string) (Required)


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/twitter/actions/twitter-poststatus-2.php

	public function statuses_update( $status, $media_id = '' ) {

		// Get twitter credentials.
		$request_body = Automator()->helpers->recipe->twitter->get_client();

		$url = Automator()->helpers->recipe->twitter->automator_api;

		$request_body['action']    = 'statuses_update';
		$request_body['status']    = $status;
		$request_body['media_ids'] = $media_id;

		$args         = array();
		$args['body'] = $request_body;

		$response = wp_remote_post( $url, $args );

		if ( is_array( $response ) && ! is_wp_error( $response ) ) {

			$body = json_decode( wp_remote_retrieve_body( $response ) );

			if ( ! isset( $body->error ) ) {

				return $body->data;

			} else {

				throw new \Exception( $body->error->description );

			}
		} else {

			$error_msg = $response->get_error_message();

			throw new \Exception( $error_msg );
			
		}

	}