There was a script on the server that worked with api facebook for a year.
$json_object = file_get_contents('https://graph.facebook.com/' . $page_id . '/feed?fields=permalink_url&limit=5&access_token=' . $access_token); Now the hoster has pissed off something and everything flew (on LAN everything continues to work), requests do not reach Facebook. I understand they changed the parameter allow_url_fopen . How to rewrite this query under cUrl? or somehow solve the problem that would work? Now he writes:
Warning: file_get_contents(***): failed to open stream: Π ΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΠΈ ΠΎΡΠΊΠ°Π·Π°Π½ΠΎ in ***.php on line 18 Notice: Trying to get property of non-object in ***.php on line 26 Warning: Invalid argument supplied for foreach() in ***.php on line 28 Rewritten under curl:
// 1. ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΡ $ch = curl_init(); // 2. ΡΠΊΠ°Π·ΡΠ²Π°Π΅ΠΌ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ, Π²ΠΊΠ»ΡΡΠ°Ρ url curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/****/feed?fields=permalink_url&limit=5&access_token=****"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); // 3. ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ HTML Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ° $output = curl_exec($ch); echo $output; if ($output === FALSE) { //Π’ΡΡ-ΡΠΎ ΠΌΡ ΠΎ Π½Π΅ΠΉ ΠΈ ΡΠΊΠ°ΠΆΠ΅ΠΌ echo "cURL Error: " . curl_error($ch); return; } // 4. Π·Π°ΠΊΡΡΠ²Π°Π΅ΠΌ ΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΠ΅ curl_close($ch); Received:
cURL Error: couldn't connect to host Maybe the https problem?