search

Home  >  Q&A  >  body text

jquery - How to receive and print out json data using php?

Suppose another domain provides me with a json
How do I get it and print it out using php? ? !

曾经蜡笔没有小新曾经蜡笔没有小新2799 days ago764

reply all(3)I'll reply

  • 为情所困

    为情所困2017-06-14 10:51:41

    file_get_contents('php://input');
    $_REQUEST

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-14 10:51:41

    // 初始化cURL
    $ch = curl_init();
    
    // 设置选项
    curl_setopt($ch, CURLOPT_URL, '你的网址');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    
    // 执行并获取文档内容
    $contents = curl_exec($ch);
    
    // 释放 curl
    curl_close($ch);
    
    // 打印获得的数据
    print_r( json_decode($contents) );

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-14 10:51:41

    The two people above said the same thing, so I won’t say more. The question is, is your json a standard json? If so, I just assume that you collect it from JD.com (not counting JD.com providing it to you) ), the json obtained is used by javascript, which is not standard for php. You must complete the quotation marks before it can be used by php

    reply
    0
  • Cancelreply