$url, 'title' => $url_title ); $payload = json_encode( $data ); $response = wp_remote_post( $apiv4, array( 'headers' => array( 'Authorization' => 'Bearer ' . $api_key, 'Content-Type' => 'application/json', ), 'body' => $payload, 'timeout' => 30, ) ); $result = wp_remote_retrieve_body( $response ); $resultToJson = json_decode( $result ); if ( isset( $resultToJson->link ) ) { $url = $resultToJson->link; } break; } return $url; } }