首页 > 解决方案 > 我在托管服务中做 curl 有问题(godaddy)

问题描述

我在连接到我的服务器脚本时遇到问题。我有一个经济的 Godaddy 托管我在 php 中编写了一个脚本来连接到我使用 mavens poker appliaction 的游戏服务器。我在本地做了所有事情并且它的工作正常但是当我把我的代码放在godaddy主机中时它没有连接我认为我对godaddy主机的卷曲有问题。我在 php.ini 中添加了 extension = curl.so,但它也不起作用。

有我的脚本卷曲页面

    <?php

   $url = "http://37.61.213.122:8087/api"; 
  $pw = "aTWdehnxuIenpiFI";                    





  function Poker_API($params)
  {
    global $url, $pw;
    $params['Password'] = $pw;
    $params['JSON'] = 'Yes';
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($curl);
    if (curl_errno($curl)) $obj = (object) array('Result' => 'Error', 'Error' => curl_error($curl)); 
    else if (empty($response)) $obj = (object) array('Result' => 'Error', 'Error' => 'Connection failed'); 
    else $obj = json_decode($response);
    curl_close($curl);
    return $obj;
  }

?>

我需要在服务器上为我做一个我的功能

 <?php
 include('api.php') ;

    $username = $_SESSION['username'];


            function showBalance (){
                global $username;
     $params = array("Command" => "AccountsGet", "Player" => $username);
    $api = Poker_API($params);  
        echo $api-> Balance;    
            }


                        function showUsername (){
                global $username;
     $params = array("Command" => "AccountsGet", "Player" => $username);
    $api = Poker_API($params);  
        echo $api-> Player; 
            }


 function  showEmail (){
            global $username;
     $params = array("Command" => "AccountsGet", "Player" => $username);
    $api = Poker_API($params);  
        echo $api-> Email;  
 }

 function  showlastLogin (){
            global $username;
     $params = array("Command" => "AccountsGet", "Player" => $username);
    $api = Poker_API($params);  
        echo $api-> LastLogin;  
 }



 function doAccountsIncBalance ($amountinc) {
                global $username;
     $params = array("Command" => "AccountsIncBalance", "Player" => $username, "Amount" => $amountinc);
    $api = Poker_API($params);       
 }


  function doAccountsDecBalance ($amountinc) {
                global $username;
     $params = array("Command" => "AccountsDecBalance", "Player" => $username, "Amount" => $amountinc);
    $api = Poker_API($params);       
 }









?>

我不知道是什么问题,但它在本地工作得很好

标签: phpcurl

解决方案


我测试了你的脚本并且它正在工作。然后我做了一些研究,从我发现的情况来看,这似乎是爸爸托管问题。因此,您最好纠正他们并询问如何使您的脚本工作或找到更可靠的托管。


推荐阅读