首页 \ 问答 \ 如何获取cURL信息(How to get cURL information)

如何获取cURL信息(How to get cURL information)

我有一个cURL脚本,它连接到一个页面:

<?php 
// create curl resource 
$ch = curl_init(); 

// set url 
curl_setopt($ch, CURLOPT_URL, "example.com"); 

//return the transfer as a string 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

// $output contains the output string 
$output = curl_exec($ch); 

// close curl resource to free up system resources 
curl_close($ch);      
?>

该页面提供了如下输出:

{
  "status" : "fail",
  "data" : {
    "error_message" : "Destination address 37428963298746238 is invalid for Network=BTC."
  }
}

如何使用PHP将“error_message”输入$error_message


I have a cURL script that makes connection to a page:

<?php 
// create curl resource 
$ch = curl_init(); 

// set url 
curl_setopt($ch, CURLOPT_URL, "example.com"); 

//return the transfer as a string 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

// $output contains the output string 
$output = curl_exec($ch); 

// close curl resource to free up system resources 
curl_close($ch);      
?>

And that page gives an output like:

{
  "status" : "fail",
  "data" : {
    "error_message" : "Destination address 37428963298746238 is invalid for Network=BTC."
  }
}

How do I get "error_message" to $error_message with PHP?


原文:https://stackoverflow.com/questions/44432774
更新时间:2023-10-01 18:10

最满意答案

double sum=0.0;
for(int i=0;i<addMe.length;i++)
{
  if(i%12==0 && i!=0)
  {
    System.out.println(sum);
    sum=0;
  }

  sum +=addMe[i];
}

double sum=0.0;
for(int i=0;i<addMe.length;i++)
{
  if(i%12==0 && i!=0)
  {
    System.out.println(sum);
    sum=0;
  }

  sum +=addMe[i];
}

相关问答

更多
  • 您最好的选择是以不同的顺序执行您的操作。 如果我错了,请纠正我,但你要做的事情可以分为三个目标: 逐行读取文件中的数字 获取一行中所有数字的总和 将读入的所有数字转换为数据结构,其中每个数字作为数组元素存在 使用诸如BufferedReader类的Reader类逐个流式传输行。 现在获取每行的数字总和, 然后将数字分解为新的数据结构。 将每个标记分解为数字数组可以通过创建新对象来实现,该新对象采用整数并将其作为整数数组存储在对象中。 Your best bet would be to perform you ...
  • 如果它真的那么大,你需要BigInteger 。 万亿。 长就够了 You need BigInteger if its really that large. For trillion. Long is enough
  • 您可以使用parseInt函数来转换拆分为整数时返回的字符串: number = parseInt(number[0], 10); numberk = parseInt(numberk[0], 10); 现在2个变量是整数,你可以对它们执行整数运算。 You could use the parseInt function in order to convert the string returned when spliting into integer: number = parseInt(number[ ...
  • 你可以在O(n)中这样做。 通过数组迭代并计算所有数字的总和。 现在,从1到N的自然数的和可以表示为Nx(N+1)/2 。 在你的情况下,N = 100。 从Nx(N+1)/2减去数组的总和,其中N = 100。 那是丢失的数字。 可以在计算和的迭代中检测空槽。 // will be the sum of the numbers in the array. int sum = 0; int idx = -1; for (int i = 0; i < arr.length; i++) { if (ar ...
  • 这可能对你有所帮助 public static Student[] createArray() { System.out.println("Enter size of array:"); Scanner userInputEntry = new Scanner(System.in); int inputLength =userInputEntry.nextInt(); Student students[] = new Student[inputLength]; ...
  • 你在问Boolean对象或boolean元吗? 对象的大小可能是16个字节(尽管可能依赖于实现),而boolean可能消耗4个字节(隐式使用int )。 因此boolean[]将消耗N * 4个字节(其中N是数组的大小)+一些对象头。 Boolean[]将消耗N * 16 +标头(根据您对Boolean大小的假设)。 这就是说考虑编写自己的类似数组的类并在一个int打包32个布尔值(你必须手动编写几个位操作),就像BitSet类正在做的那样。 Are you asking about Boolean obj ...
  • 更具体地说,您正在寻找您的数字集合的幂集中的每个集合的特定总和。 您可以使用以下代码完成此操作。 function powerset(arr) { var ps = [[]]; for (var i=0; i < arr.length; i++) { for (var j = 0, len = ps.length; j < len; j++) { ps.push(ps[j].concat(arr[i])); } } re ...
  • 数组必须具有固定大小。 如果您事先不知道大小,请改用ArrayList 。 将值添加到ArrayList ,可以创建一个数组(其大小基于ArrayList的元素数)并将数据复制到该ArrayList 。 An array must have a fixed size. If you don't know the size in advance, use an ArrayList instead. After you finish adding the values to the ArrayList, you ...
  • 数组没有“自然顺序”,这就是你得到这个例外的原因。 一种方法是在构造TreeSet时提供自定义比较器。 Set s = new TreeSet(new Comparator() { @Override public int compare(String[] o1, String[] o2) { //your logic here } }); 但是我不认为你应 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。