Get_meta_tags does not work for the same domain or source

I am trying to use the get_meta_tags function to get url meta information. he did not give me url meta information from the same source or domain.

how do i do it from the controller http://example.com/fetch

$tags=get_meta_tags("http://example.com/blog/my-awesome-blog-post"); print_r($tags); 

trying to get metainfo pages on my site http://example.com/blog/my-awesome-blog-post . Sharing two screenshots:

Dev instance error: Error Dev

Local instance:

Local image

Receiving an error, for example , could not open the stream: redirection limit reached, interrupted. This is the error I am getting.

I tried to use different urls (except facebook). I get successful results.

In any case, I can achieve this functionality.

+5
source share
1 answer

I do not know about your localhost , but this is what I deduced from your script.

Your website (or the page you are accessing) constantly redirects to a new URL every time PHP tries to access the URL. When the maximum redirect limit is reached, i.e. PHP, PHP stops following and gives you an error.

This is because a PHP request is a simple http request that does not process session / cookie values. Thus, your site always considers it as a new request and saves the redirect.

To check, please note that when you open the URL ( https://dev.kidengage.com/library ) in an incognito window, it redirects you to https://dev.kidengage.com/hyderabad to set the location for the user. And, after the cookies are set, no more redirection occurs for this URL.

Here redirects occur.

So, you need to fix this first or write a custom CURL script to retrieve data that can handle the session, as well as redirects.

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1274497/


All Articles