1

私は今4時間答えを探していましたが、まだ解決できません。

Curl error: couldn't connect to host 

私が得るエラーです...彼らはそれがSSLの問題かもしれないと言います...

私は使用して000webhostおり、ここでテストを確認できます: http://www.feriajanos.com/src/teszt.php

私を助けてください!

これは私が使用するコードです:

   <?php
          function curl($url){
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL,$url);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt( $ch, CURLOPT_POSTFIELDS, $url );

         $response = curl_exec($ch);

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

         curl_close($ch);
         return $response;
     }

          $app_id = "MY_APP_ID";//do not show this
          $app_secret = "MY_APP_SECRET";//do not show this
          $fanpage_id ='MY_FANPAGE_ID';//do not show this
          //Take NOTE: this must include http://
          //ex. http://sharefavoritebibleverses.com/fb_connect.php        
          $post_login_url = "http://www.feriajanos.com/teszt.php";  

          //Take NOTE: this must include http://
          $photo_url = "http://www.feriajanos.com/kepek/mas/posztok/poszt20130412104817.jpg";

          //you can add link to your image caption, but you can't use this tag <a href='http://link.com' >visit my link</a>
          $photo_caption = "Feri A János";

      $code = $_REQUEST["code"];

      //Obtain the access_token with publish_stream permission 
      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