0

我得到的错误是:

Curl 错误:无法连接到主机Curl 错误:无法连接到主机

我已经尝试了几乎所有方法来解决这个问题,但它似乎不起作用 file_get_contents 也不起作用,但它已启用。

         $response = curl_exec($ch);

         if($response === false) {
             echo 'Curl error: ' . curl_error($ch);
         } else {
             $response = $response;
         }         

         curl_close($ch);
         return $response;
     }
     $app_id = "APP_ID"; 
     $app_secret = "APP_SECRET"; 
     $fanpage_id ='325145047546976';
     $post_login_url = "http://www.feriajanos.com/src/teszt.php";  
     $photo_url = "http://www.feriajanos.com/kepek/mas/posztok/poszt20130412104817.jpg";
     $photo_caption = "Feri A János";
     $code = $_REQUEST["code"];
     if (!$code) { 
        $dialog_url= "https://www.facebook.com/dialog/oauth?"
          . "client_id=" .  $app_id
          . "&redirect_uri=" . urlencode( $post_login_url)
          .  "&scope=publish_stream,manage_pages";

        echo("<script>top.location.href='" . $dialog_url
          . "'</script>");
     } 
     if(isset($_REQUEST['code'] )) {
        $token_url="https://graph.facebook.com/oauth/access_token?"
          . "client_id=" . $app_id
          . "&client_secret=" . $app_secret
          . "&redirect_uri=" . urlencode( $post_login_url)
          . "&code=" . $code;


        $response = curl($token_url);

        $params = null;
        parse_str($response, $params);
        $access_token = $params['access_token'];

        // POST to Graph API endpoint to upload photos
        $graph_url= "https://graph.facebook.com/me/photos?"
          . "url=" . urlencode($photo_url)
          . "&message=" . urlencode($photo_caption)
          . "&method=POST"
          . "&access_token=" .$access_token;

        echo '<html><body>';

           echo curl($graph_url);

        echo '</body></html>';
      }
    ?>
4

0 回答 0