GAE app : Warning: file_get_contents(): Unknown status code

89 views
Skip to first unread message

Ken Walker

unread,
Jul 29, 2016, 7:20:11 AM7/29/16
to Google App Engine
Hello,

Why we are getting this warning + we are not getting full content from the file by GAE app so, can you please check and correct me, please check below code that we are using with GAE app

-----------------------------------------
$opts = array('http'=>array(
                    'method'=>"GET",
                    'header'=>"Accept-language: en\r\n" .
                    "Accept-Encoding: gzip, deflate, br\r\n",
                    'user_agent'=>"User-Agent: my agent\r\n" // i.e. An iPad
            )
    );

$context = stream_context_create($opts);
$content = file_get_contents($url ,false,$context);
-----------------------------------------

Thanks in advance!
- Ken Walker

Nicholas (Google Cloud Support)

unread,
Aug 2, 2016, 1:58:34 PM8/2/16
to Google App Engine
Thanks for sharing this finding here.  I cannot yet reproduce this warning with the code sample provided above.  This is the original code I used.  The test file used was a 32KB text file of Lorem Ipsum.

I get the complete file when testing this.  Using Stackdriver Trace, one can inspect the underlying URL Fetch call made to Cloud Storage.
  • What response status code do you get with that underlying URL Fetch call?
  • How large is the file being fetched?  I suspect this may affect the response code if Cloud Storage responds with a 206 splitting the file.

Ken Walker

unread,
Aug 3, 2016, 1:51:32 AM8/3/16
to Google App Engine
Thank you for your replay

As we have faced that with linkedin public profile url, please check it below
------------------------------
$url ='https://www.linkedin.com/in/amitgupta007'

$opts = array('http'=>array(
                    'method'=>"GET",
                    'header'=>"Accept-language: en\r\n" .
                    "Accept-Encoding: gzip, deflate, br\r\n",
                    'user_agent'=>"User-Agent: my agent\r\n" // i.e. An iPad
            )
    );

$context = stream_context_create($opts);
$content = file_get_contents($url ,false,$context);
-----------------------------------------

Thanks in advance!

Ken Walker

unread,
Aug 3, 2016, 1:52:41 AM8/3/16
to Google App Engine
we got response code  : 999

Nicholas (Google Cloud Support)

unread,
Aug 3, 2016, 10:16:09 AM8/3/16
to Google App Engine
Ah I see.  My apologies.  When you said file, I assumed you were trying to retrieve an object from Cloud Storage.  This is simply attempting to systematically retrieve a public profile from a linkedin URL.

The error status 999 is commonly returned by linkedin servers in response to unauthorized requests.  According to their Terms of Service, the act of retrieving pages with software violates said terms.
Use manual or automated software, devices, scripts robots, other means or processes to access, “scrape,” “crawl” or “spider” any web pages or other services contained in the site;

To get information from linkedin, it seems you must use their API.  Like many APIs, you'll need a Client ID, Client Secret Value, etc.  I would suggest consulting that documentation before attempting further.  Hope this helps and happy coding!


On Friday, July 29, 2016 at 7:20:11 AM UTC-4, Ken Walker wrote:
Reply all
Reply to author
Forward
0 new messages