Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error: ErrorException (API-E) #17

Closed
wants to merge 1 commit into from

Conversation

revise-dev[bot]
Copy link

@revise-dev revise-dev bot commented Sep 28, 2024

The error we're encountering is related to parsing XML data using the simplexml_load_string() function. The specific error message suggests that there's an issue with the XML structure, particularly with the Public Identifier.

To fix this error, we need to modify the RefreshSportsCalendar job in the app/Jobs/RefreshSportsCalendar.php file. Here's a detailed explanation of the changes:

  1. We're changing the way we fetch and parse the XML feed. Instead of directly passing the HTTP response to simplexml_load_string(), we'll first get the response body as a string.

  2. We'll use Http::get()->body() instead of just Http::get() to ensure we're working with the raw response content.

  3. Before parsing the XML, we'll trim any whitespace from the beginning and end of the response to avoid potential issues with leading or trailing spaces.

  4. We'll wrap the XML parsing in a try-catch block to handle any potential parsing errors gracefully. This will prevent the job from crashing if there are issues with the XML structure.

  5. If there's an error parsing the XML, we'll log it for debugging purposes and return early from the job.

  6. We'll only proceed with processing the feed items if the XML was successfully parsed.

These changes should resolve the XML parsing error and make the job more robust in handling potential issues with the feed.

Revisions or follow-up questions

You can make revisions or ask questions of Revise.dev by using /revise in any comment or review!

  • /revise Add a comment above the method to explain why we're making this change.
  • /revise Why did you choose to make this change specifically?

@jxxe jxxe closed this Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant