Coder Social home page Coder Social logo

craftcms / apple-news Goto Github PK

View Code? Open in Web Editor NEW
41.0 9.0 8.0 860 KB

Publish your Craft CMS content with Apple News Format.

Home Page: https://craftcms.com/apple-news

License: MIT License

PHP 98.39% Twig 1.20% PLpgSQL 0.41%
craftcms craft-plugin craft2 apple-news apple-news-format apple-news-channels

apple-news's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apple-news's Issues

Make connection timeout configurable

Description

When saving / updating articles, we routinely run into the following error:

Array
(
    [code] => 28
    [message] => Operation timed out after 30000 milliseconds with 0 bytes received
    [response] => 
)
 in /app/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php on line 197

When this issue occurs, often times the article is created on the Apple News side - but none of the meta data makes it back into Craft - creating 'disconnected' Apple News entries. We address this by manually pulling the meta data from apple news and updating the database.

I concede that this could be from our content (which tends to be long / rich), or our article class implementation. But maybe others see this issue as well?

It would be great if we could configure the timeout for the connection, (adding say another option in the config files) to allow for a longer timeout for publishers like us.

Craft 3?

Will this get updated for Craft 3?

Craft error when attempting to edit an entry with emoji

Craft supports some emoji

If add an allowed emoji to an entry (e.g. 👍 in the source view of a Redactor field, to render ๐Ÿ‘), save the entry, and then try to edit the entry, I get

Array
(
[code] => 400
[message] => HTTP/1.1 400 Bad Request
[response] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => NOT_ALLOWED
)

)

)

)
in </path/to>/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php on line 197
</path/to>/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php(289)

277   /**
278    * Error handler.
279    *
280    * @param (string) $message Error message to display.
281    * @param (const) $message_type Predefined Constants
282    *
283    * @see http://php.net/manual/en/errorfunc.constants.php
284    */
285   public function triggerError($message, $message_type = E_USER_NOTICE) {
286     $debug_backtrace = debug_backtrace();
287     $trace = $debug_backtrace[0];
288     trigger_error($message . ' in ' . $trace['file'] . ' on line ' .
289       $trace['line'], $message_type);
290   }
291 
292 }

Guessing this is a plugin bug, sending an unexpected character to chapter-three's apple-new-api?

Can not delete entries with the Apple News plugin enabled.

Iโ€™m building a site that uses the Apple News plugin, and for some reason when I try to delete an entry Iโ€™m running into an error (see attached screenshot). It appears that this error is related to the Apple News plugin, because when I disable the plugin I can delete entries without issue. This error occurs both when I try to delete an entry in the CMS, as well as when I try to delete an entry via php in a module.
Screen Shot 2020-01-31 at 6 00 22 PM

Does addFile not work with asset transforms?

When I download a News Preview where images use asset transforms, images are no longer generated.

Without a transform, images are generated and display at the original size.

I've tried our normal S3 setup and a local file structure and have the same issue with both.

Failed Task & PHP error 400

I'm currently getting a failed task showing PHP error code 400 in the stack trace below. Currently on v1.0.2. Any ideas on how best to troubleshoot this?

2018/01/11 19:29:02 [error] [php] Array
(
    [code] => 400
    [message] => HTTP/1.1 400 Bad Request
    [response] => stdClass Object
        (
            [errors] => Array
                (
                    [0] => stdClass Object
                        (
                            [code] => INVALID_DOCUMENT
                            [keyPath] => Array
                                (
                                    [0] => components
                                    [1] => 3
                                    [2] => text
                                )

                            [message] => "text" was null should be not (null or an empty string)
                        )

                )

        )

)
 in /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php on line 197 (/storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php:289)
Stack trace:
#0 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php(197): ChapterThree\AppleNewsAPI\PublisherAPI->triggerError()
#1 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Curl.php(104): ChapterThree\AppleNewsAPI\PublisherAPI->onErrorResponse()
#2 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Curl.php(88): ChapterThree\AppleNewsAPI\PublisherAPI->response()
#3 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Curl.php(242): ChapterThree\AppleNewsAPI\PublisherAPI->request()
#4 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/services/AppleNews_ApiService.php(153): ChapterThree\AppleNewsAPI\PublisherAPI->post()
#5 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/services/AppleNews_ApiService.php(89): Craft\AppleNews_ApiService->post()
#6 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/services/AppleNewsService.php(341): Craft\AppleNews_ApiService->createArticle()
#7 /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/tasks/AppleNews_PostQueuedArticlesTask.php(91): Craft\AppleNewsService->postArticle()
#8 /storage/av04810/www/app/releases/1515524613/craft/app/services/TasksService.php(239): Craft\AppleNews_PostQueuedArticlesTask->runStep()
#9 /storage/av04810/www/app/releases/1515524613/craft/app/services/TasksService.php(200): Craft\TasksService->runTask()
#10 /storage/av04810/www/app/releases/1515524613/craft/app/controllers/TasksController.php(89): Craft\TasksService->runPendingTasks()
#11 /storage/av04810/www/app/releases/1515524613/craft/app/framework/web/actions/CInlineAction.php(49): Craft\TasksController->actionRerunTask()
#12 /storage/av04810/www/app/releases/1515524613/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams()
#13 /storage/av04810/www/app/releases/1515524613/craft/app/framework/web/CController.php(286): Craft\TasksController->runAction()
#14 /storage/av04810/www/app/releases/1515524613/craft/app/framework/web/CController.php(265): Craft\TasksController->runActionWithFilters()
#15 /storage/av04810/www/app/releases/1515524613/craft/app/framework/web/CWebApplication.php(282): Craft\TasksController->run()
#16 /storage/av04810/www/app/releases/1515524613/craft/app/etc/web/WebApp.php(823): Craft\WebApp->runController()
#17 /storage/av04810/www/app/releases/1515524613/craft/app/etc/web/WebApp.php(287): Craft\WebApp->_processActionRequest()
#18 /storage/av04810/www/app/releases/1515524613/craft/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#19 /storage/av04810/www/app/releases/1515524613/craft/app/index.php(62): Craft\WebApp->run()
#20 /storage/av04810/www/app/releases/1515524613/public/index.php(14): require_once()
REQUEST_URI=/index.php?p=admin/actions/tasks/rerunTask
2018/01/11 19:29:02 [error] [application] Encountered an error running task 139 (AppleNews_PostQueuedArticles), step 1 of 2: Array
(
    [code] => 400
    [message] => HTTP/1.1 400 Bad Request
    [response] => stdClass Object
        (
            [errors] => Array
                (
                    [0] => stdClass Object
                        (
                            [code] => INVALID_DOCUMENT
                            [keyPath] => Array
                                (
                                    [0] => components
                                    [1] => 3
                                    [2] => text
                                )

                            [message] => "text" was null should be not (null or an empty string)
                        )

                )

        )

)
 in /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php on line 197 on line 289 of /storage/av04810/www/app/releases/1515524613/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php

Unable to publish to Apple News

I'm unable to publish articles to Apple News. My API keys and secret are correct, as I am able to view correctly-named sections set within News Publisher in the CP. I'm not able to see the Apple News pane on the right side of entries while editing, but the option to publish is visible in the gear menu on the entries index. However, this option is available for all entries, not just the ones specified in the channel class.

I'm using the included example templates, MyNewsArticle.phpand MyNewsChannel.php, both tailored to fit my section/entry handles and news entry matrix structure where necessary.

Maybe relevant: when I follow the link from inside the plugin, I get a {"errors":[{"code":"UNAUTHORIZED"}]} response.

Unable to Delete Entry if It's in applenews_article Table

Description

Similar issue to this bug #11 however my error is a return type error (see screenshot)
The deleteArticle method is expecting a return type of stdClass but I actually get an empty string. Following the chain of methods

` public function deleteArticle(string $channelId, string $articleId): stdClass
{
return $this->delete($channelId, '/articles/{article_id}', [
'article_id' => $articleId,
]);
}

calls

/**
 * Sends a DELETE request to the Apple News API.
 *
 * @param string $channelId
 * @param string $path
 * @param array $pathArgs
 * @param array $data
 * @return mixed
 */
protected function delete(string $channelId, string $path, array $pathArgs = [], array $data = [])
{
    return $this->api($channelId)->delete($path, $pathArgs, $data);
}

which instantiates publisherAPI which then calls

/**

  • Create DELETE request to a specified endpoint.
  • @param (string) $path API endpoint path.
  • @param (string) $path_args Endpoint path arguments to replace tokens in the path.
  • @param (string) $data Raw content of the request or associative array to pass to endpoints.
  • @return object Preprocessed structured object and returns 204 No Content on success, with no response body.
    */
    public function delete($path, Array $path_args = [], Array $data = []) {
    parent::delete($path, $path_args, $data);
    $this->setHeaders(
    [
    'Authorization' => $this->auth()
    ]
    );
    $this->unsetHeaders(
    [
    'Content-Type'
    ]
    );
    return $this->request($data);
    }`

We haven't changed anything on our end so this is a little strange. Unless the news api has changed their responses.

Steps to reproduce

Additional info

  • Craft version: 3.7.63.1
  • PHP version: 8
  • Database driver & version:
  • Plugins & versions: 2.0.1

Task Error

I'm getting the following error in the logs because all Apple News tasks are failing.

Any ideas what could be causing this? I can download the content from the articles in the task and preview it in the News Preview app (Just to double check there were no errors with the way the article was formatted)

2017/11/22 10:14:47 [error] [application] Encountered an error running task 63856 (AppleNews_PostQueuedArticles), step 1 of 4: Array
(
    [code] => 404
    [message] => HTTP/1.1 404 Not Found
    [response] => stdClass Object
        (
            [errors] => Array
                (
                    [0] => stdClass Object
                        (
                            [code] => NOT_FOUND
                            [keyPath] => Array
                                (
                                    [0] => articleId
                                )

                            [value] => 206516d9-4401-4b23-8338-5e5e8cf637fa
                        )

                )

        )

)
 in /home/website/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php on line 197 on line 289 of /home/website/craft/plugins/applenews/vendor/chapter-three/apple-news-api/src/PublisherAPI/Base.php

Error when trying to access another plugin's service

I have a plugin to generate a YouTube/Vimeo video URL based on the web URL of the video, and I am trying to access it inside MyNewsArticle.php.

$videoUrl = craft()->videoEmbed->getEmbedUrl($block->videoUrl);

I got the error Call to undefined function craft() and noticed that this file isn't using the Craft namespace. What is the best way for me to access other plugins' services?

htmlConverter must not be accessed before initialization

Description

Typed static property craft\applenews\Helper::$_htmlConverter must not be accessed before initialization

Steps to reproduce

  1. publish article
  2. view the queue manager, job fails

Additional info

  • Craft version: 4
  • PHP version: 8.2.7

Bad symlink in vendor package `php-curl-class`

Trying to commit the plugin to git via SourceTree, I get the error:

sourcetreescreensnapz002

And indeed, the php-curl-class has the following bad symlink in it:

vagrant@homestead /htdocs/nystudio107/craft/plugins/applenews/vendor/php-curl-class/php-curl-class/examples (master) $ pwd
/htdocs/nystudio107/craft/plugins/applenews/vendor/php-curl-class/php-curl-class/examples
vagrant@homestead /htdocs/nystudio107/craft/plugins/applenews/vendor/php-curl-class/php-curl-class/examples (master) $ ls -al | grep vendor
lrwxrwxrwx  1 501 dialout    9 Dec 30 06:33 vendor -> ../vendor
vagrant@homestead /htdocs/nystudio107/craft/plugins/applenews/vendor/php-curl-class/php-curl-class/examples (master) $

Minor, but I figured I'd note it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.