Why does wp_update_post causes white screen?

I made a custom post type, named “Foglalás”. Each post in the Foglalás post type has neither title nor permalink. All of them are kind of Auto Draft after saving. So, I would like to get the post ID and set it to be the title and permalink as well. I use the following code:

Automatically fill custom field value on post publish/update

I’ve searched around a bit, and I’m having trouble finding an answer to this question. What I’m trying to do is automatically fill a custom field when a post (custom post type) is updated or published. Ideally the completed script will call out to an API and fill the custom field with the resulting information whenever a post is created or updated. For right now though, I’m just trying to automatically fill my custom field with a simple string for testing. Here’s my code: