alleyinteractive / apple-news

The Publish to Apple News plugin enables your WordPress blog content to be published to your Apple News channel.
https://wordpress.org/plugins/publish-to-apple-news/
GNU General Public License v3.0
153 stars 71 forks source link

Plugin cannot be used if allow_url_fopen is unsupported #118

Closed preshit closed 8 years ago

preshit commented 8 years ago

Running v1.0.6 of the plugin, when trying to publish a post, it throws the following error:

There has been an error with the API. Please make sure your API settings are correct and try again: The attachment could not be included in the request because it was empty.

bcampeau commented 8 years ago

This is the more verbose error message that we added to help troubleshoot issue #92. Can you provide the JSON file that encountered this error and a link to the post on your site?

Thanks.

preshit commented 8 years ago

Here are the links to the posts: 1, 2

JSON-BPXL.zip

FYI, we use Featured Images on all our posts and the error is thrown for all those posts.

I'd be happy to provide any additional info you need. Thank you.

bcampeau commented 8 years ago

The most likely scenario here is that your host is doing something to disable file_get_contents, which is required to get the image file and include it in the bundle. Can you please rule out that possibility first?

preshit commented 8 years ago

@bcampeau Sure thing! I'll contact my host and update this issue with what they have to say.

Thanks!

bcampeau commented 8 years ago

Specifically they may need to enable allow_url_fopen in your PHP config.

thgoepel commented 8 years ago

I am seeing the same error and to test turned on allow_url_fopen and still getting same error message:

There has been an error with the API. Please make sure your API settings are correct and try again: The attachment IMG_xxxx.png could not be included in the request because it was empty.

bcampeau commented 8 years ago

Can you please provide a link to the image and the post on your site?

thgoepel commented 8 years ago

One thing I realized then turning on allow_url_fopen the error is pointing to the first image instead of the featured image when allow_url_fopen is off.

bcampeau commented 8 years ago

OK, we'll need to see the JSON file and a link to the actual post to help you.

thgoepel commented 8 years ago

Attached the JSON file: article-403.json.zip

And here his the link to the actual post: http://blog.ticoroasters.com/2015/05/quest-for-perfect-coffee-los-andes/

The link to the actual pic for allow_url_fopen turned on: http://i2.wp.com/blog.ticoroasters.com/wp-content/uploads/2015/05/IMG_5872.png

The link to the pic for allow_url_fopen off error: http://i2.wp.com/blog.ticoroasters.com/wp-content/uploads/2015/05/IMG_5872-180x300.png

Hope this will help ..

preshit commented 8 years ago

Here's what my host had to say:

file_get_contents is dependent on allow_url_fopen which has been disabled on our [service] for security reasons.

We do support CURL as an alternative to url_fopen. Your plugin author should know if they are using these functions or not.

bcampeau commented 8 years ago

There are other hosts that don't support cURL, like WordPress.com VIP, so this was the chosen method. Unfortunately at this time, if your host doesn't support this function, you can't use this plugin.

I'll leave this issue open as I think it will be worthwhile reconsidering if there's a better way to handle this.

thgoepel commented 8 years ago

Did you have a chance to look into my problem? As mentioned I have allow_url_fopen turned on and still get the following error message:

There has been an error with the API. Please make sure your API settings are correct and try again: The attachment IMG_5872.png could not be included in the request because it was empty.

The JSON file and links are above ... Thanks for your help!

bcampeau commented 8 years ago

Unfortunately I'm not seeing any reason for the error to occur. I don't have a solution for you at this time.

thgoepel commented 8 years ago

Well, is there a way to turn on debugging so I can see where it fails? I also tried to just push a text post and I get the following error:

There has been an error with the API. Please make sure your API settings are correct and try again: INVALID_DOCUMENT

Maybe this gives you an idea what it could be? Thanks for any help!

bcampeau commented 8 years ago

You need to export the JSON file, download the images, and drop them into a folder. That folder can then be dragged into the News Preview tool (https://developer.apple.com/news-preview) which will give you more detailed errors. Once you have those, please feel free to paste them here and I can give more feedback.

Thanks.

bcampeau commented 8 years ago

@thgoepel are you still looking for assistance here? If not, we'll be closing this issue as there isn't any further action on our end otherwise.

Thanks.

thgoepel commented 8 years ago

@bcampeau yes I still have not been able to get it to work. The only way it seems I can get it to work is without any pictures. As soon as there is a picture in the blog post, the post does not get exported. I have checked with the new preview and could not find any error. I am wondering if there is a permission issue somewhere in the wordpress filesystem. Is there a temporary folder where the images get saved into before uploaded to apple-news?

bcampeau commented 8 years ago

We do not use the filesystem because some hosts wouldn't support that. Images are streamed directly to the API from wherever they are located. INVALID_DOCUMENT however indicates a formatting issue. Have you been able to use the News Preview tool to get the actual error? If not, we did request a sample bundle from you that was failing so we could help troubleshoot. We'll need one of those two things to be able to assist you here.

Thanks.

thgoepel commented 8 years ago

@bcampeau I have used the News-Preview Tool and when I have images I get the following warning:

Warning: Anchor with targetComponentIdentifier [TextComponent-26] is out of range. Range has been removed.

When it is text only then there is no warning. I guess I have to play more to see what part of the post it is acting up with. You can see the son file and the image in an earlier post that I provided.

Do you have any ideas what it could be?

bcampeau commented 8 years ago

Are you referring to article-403.zip in https://github.com/alleyinteractive/apple-news/issues/118#issuecomment-202951034?

thgoepel commented 8 years ago

Here you go. Added one of the articles as a complete package. The weird thing is that is works in the iPad preview and throws an error in the iPhone preview. Would appreciate if you have any ideas ... Thanks so much!

article-922.zip

bcampeau commented 8 years ago

Closing this in favor of #163 which provides a more robust solution using the API directly.