php - 我在托管服务中做 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);
}
?>
我不知道是什么问题,但它在本地工作得很好
解决方案
我测试了你的脚本并且它正在工作。然后我做了一些研究,从我发现的情况来看,这似乎是爸爸托管问题。因此,您最好纠正他们并询问如何使您的脚本工作或找到更可靠的托管。
推荐阅读
- haskell - 如何使用 `binary` 将 5 字节的内容读入 `Word64`?
- elasticsearch - Elasticsearch:如何排名高的完全匹配?
- python - 是否有一种更简单、更快捷的方法来获取索引 dict,其中包含列表或 numpy 数组中相同元素的索引
- tensorflow - 如何检查 tflite 文件中的量化权重
- node.js - 为什么节点 cron 不在 forEach() 中运行?
- html - 如何创建水平显示项目的组合框?
- bash - Bash 模式匹配循环超级慢
- python - Tensorflow 序列到序列 CustomHelper
- maven - 添加了 Intellij 模块依赖,但编译仍然失败
- python - Python - 取列中第一个日期的时间差