Bolandish / PHP-Instagram-Grabber

A workaround for the new Instagram policy to get images by hashtag and user id. No need for accesstoken :)
151 stars 39 forks source link

Truncated answer from file_get_contents #23

Open paha77 opened 7 years ago

paha77 commented 7 years ago

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()?

Bolandish commented 7 years ago

Thanks for the pull request

paha77 commented 7 years ago

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.

freddurst1805 commented 7 years ago

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 !

Vassard commented 7 years ago

@freddurst1805 have you update the script to 1.0.10?

freddurst1805 commented 7 years ago

How can I update it directly from my project ?

Vassard commented 7 years ago

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

freddurst1805 commented 7 years ago

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

freddurst1805 commented 7 years ago

I get null response for any hashtag I use

Vassard commented 7 years ago

You need curl else it will return false

freddurst1805 commented 7 years ago

I use cURL in other parts of my project

Vassard commented 7 years ago

have you try example.php

freddurst1805 commented 7 years ago

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

freddurst1805 commented 7 years ago

The cURL request return false ( function getContentsFromUrl() )

Vassard commented 7 years ago

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

freddurst1805 commented 7 years ago

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 ?

leonelfolmer commented 7 years ago

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

freddurst1805 commented 7 years ago

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 ?

paha77 commented 7 years ago

Yes it works.

freddurst1805 commented 7 years ago

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

freddurst1805 commented 7 years ago

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 !

ivanckt commented 7 years ago

Thanks fred, this works for me too