Hello,
this is not kirby related but maybe somebody can help me out:
If i open this URL with a browser i get a nice json response:
https://graph.facebook.com/oauth/access_token?redirect_uri=http://www.domain.com&client_id=456&client_secret=123&grant_type=client_credentials
gives:
{
"error": {
"message": "Error validating application. Cannot get application info due to a system error.",
"type": "OAuthException",
"code": 101,
"fbtrace_id": "Au86iVmLm9u"
}
}
a error message as expected but anyway… if i load this URL in PHP with curl or file_get_contents i always get:
["errno"]=>
int(7)
["errmsg"]=>
string(0) ""
["content"]=>
bool(false)
“errno7” i a “no route to host” error.
Why? How can i send a php curl request to get the same response as in a browser? I have tested lots of CURL_OPTs with always the same result: no route to host.
Here is some PHP code to test it. Just copy&paste the dumped URL to a browser tab… it will give you nice JSON.
$url = "https://graph.facebook.com/oauth/access_token?redirect_uri=http://www.domain.com&client_id=456&client_secret=123&grant_type=client_credentials";
$options = array(
//CURLOPT_VERBOSE => 1,
CURLOPT_RETURNTRANSFER => true, // return web page
//CURLOPT_HEADER => true, // don't return headers
//CURLOPT_FOLLOWLOCATION => true, // follow redirects
//CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36", // who am i
//CURLOPT_AUTOREFERER => false, // set referer on redirect
//CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
//CURLOPT_TIMEOUT => 120, // timeout on response
//CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
//CURLOPT_IPRESOLVE => true,
//CURL_IPRESOLVE_V4 => true,
//CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks
//CURLOPT_SSL_VERIFYHOST => 2,
//CURLOPT_SSLVERSION => 3,
//CURLOPT_CAINFO => "*facebookcom.crt",
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
echo("<pre>");var_dump($header);
greetings,
svnt