PHP-Instagram-Grabber icon indicating copy to clipboard operation
PHP-Instagram-Grabber copied to clipboard

Truncated answer from file_get_contents

Open paha77 opened this issue 8 years ago • 21 comments

I'm using the library to fetch content related to a hashtag. Sometimes (but not always) I get a FALSE returned. I've debugged the library and seen that the anwer from the URL opened with file_get_contents is truncated and the json_decode function cannot decode it.

Is it maybe a limitation in file_get_contents()?

paha77 avatar Oct 25 '16 12:10 paha77

Thanks for the pull request

Bolandish avatar Oct 28 '16 13:10 Bolandish

Unfortunately it has not fixed the issue. Sometimes (also with cURL) the answer from Instagram is truncated and therefore it's an invalid JSON string.

paha77 avatar Nov 08 '16 09:11 paha77

Is it a security response from Instagram ? I don't understand what's wrong but I personnaly cannot get anymore valid request from the scrapper !

freddurst1805 avatar Nov 24 '16 16:11 freddurst1805

@freddurst1805 have you update the script to 1.0.10?

Vassard avatar Nov 24 '16 17:11 Vassard

How can I update it directly from my project ?

freddurst1805 avatar Nov 24 '16 17:11 freddurst1805

if you use composer, else you have to download it yourself

Vassard avatar Nov 24 '16 17:11 Vassard

I tried both with Composer & Manual, but it's still not working at all ...

freddurst1805 avatar Nov 24 '16 17:11 freddurst1805

I get null response for any hashtag I use

freddurst1805 avatar Nov 24 '16 17:11 freddurst1805

You need curl else it will return false

Vassard avatar Nov 24 '16 17:11 Vassard

I use cURL in other parts of my project

freddurst1805 avatar Nov 24 '16 18:11 freddurst1805

have you try example.php

Vassard avatar Nov 24 '16 18:11 Vassard

I use the exact same function as the hashtag test. And yes I just tried and it's the same result

freddurst1805 avatar Nov 24 '16 18:11 freddurst1805

The cURL request return false ( function getContentsFromUrl() )

freddurst1805 avatar Nov 24 '16 18:11 freddurst1805

yes because you don't have curl protected static function getContentsFromUrl($parameters) { if (!function_exists('curl_init')) { return false; }

Vassard avatar Nov 24 '16 19:11 Vassard

Why can I use cURL from other files on my server and then the module is activated ? What's the problem with cURL I don't get it ?

freddurst1805 avatar Nov 24 '16 20:11 freddurst1805

If you do not have cURL enabled in your host will not work @freddurst1805

leonelfolmer avatar Nov 24 '16 21:11 leonelfolmer

Guys I have cURL installed on my local server and I use it in every project, so please ... For you everything is ok ? can you scrap by hashtag at the moment ?

freddurst1805 avatar Nov 27 '16 14:11 freddurst1805

Yes it works.

paha77 avatar Nov 27 '16 14:11 paha77

I get an error code 60 from cURL: CURLE_SSL_CACERT (60) Peer certificate cannot be authenticated with known CA certificates.

freddurst1805 avatar Nov 27 '16 14:11 freddurst1805

Adding this line seems to solve the problem: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); Now i get a code 0, so everything's fine !

freddurst1805 avatar Nov 27 '16 14:11 freddurst1805

Thanks fred, this works for me too

ivanckt avatar Dec 23 '16 06:12 ivanckt