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

Bug 302 code - Error: Failed to fetch SNlM0e #2

Closed
nghyane opened this issue May 28, 2023 · 2 comments
Closed

Bug 302 code - Error: Failed to fetch SNlM0e #2

nghyane opened this issue May 28, 2023 · 2 comments

Comments

@nghyane
Copy link

nghyane commented May 28, 2023

Update this function

    public function scrapeByRegex(string $pageURL, string $regex): string
    {
        $ch = curl_init($pageURL);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
        curl_setopt($ch, CURLOPT_COOKIE, $this->getApiKeyName() . '=' . $this->getApiKeyValue());
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        $response = curl_exec($ch);

        curl_close($ch);

        $result = [];

        preg_match($regex, $response, $result);

        if (count($result) !== 2)
        {
            throw new RuntimeException('Failed to fetch SNlM0e.');
        }

        return $result[1];
    }
@nghyane
Copy link
Author

nghyane commented May 28, 2023

update CURLOPT_FOLLOWLOCATION!

@khaledalam
Copy link
Owner

@nghyane updated, thanks.

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

No branches or pull requests

2 participants