dqd78456 2012-04-30 10:50
浏览 116
已采纳

php curl_init()无效

am trying to send SMS using the url but it's not working the result is empty this is my code

$ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);

        /**
        * Ask cURL to return the contents in a variable
        * instead of simply echoing them to the browser.
        */

        //Using Proxy
        // curl_setopt($ch, CURLOPT_PROXY, '212.138.39.84:8080');
        //

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        /**
        * Execute the cURL session
        */
$result = curl_exec ($ch);
                    /**
        * Close cURL session
        */
        curl_close ($ch);


         $result=explode("
",$result);
         $result=$result[(count($result)-1)];
     $result;

can anyone help me ???

  • 写回答

1条回答 默认 最新

  • duanri1985 2012-04-30 11:30
    关注

    try this

    <?php 
    
        $ch = curl_init ($url);
    
         /*
          * Send SMS
          */
          curl_setopt ($ch , CURLOPT_RETURNTRANSFER , TRUE);
          curl_setopt($ch , CURLOPT_TIMEOUT , 30);
    
         /*
          * Execute command and send sms
          */
    
         $result = curl_exec ($ch);
    ?>
    

    you can write below line for print out put

    <?php
          echo "<pre>";
          print_r($result); 
          echo "</pre>";
    ?>
    

    see output after parse or expload result.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效