Heim php教程 PHP源码 Codebeispiel für den Aufruf einer Finanzdatenschnittstelle für Fonds basierend auf PHP

Codebeispiel für den Aufruf einer Finanzdatenschnittstelle für Fonds basierend auf PHP

Nov 08, 2016 pm 01:40 PM

Codebeschreibung: Codebeispiel für den Aufruf einer PHP-basierten Fondsfinanzdatenschnittstelle
Zugehörige Daten: Fondsfinanzdaten

Schnittstellenadresse: http://www.juhe.cn/docs/api/id/ 28

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

<!--?php

// +----------------------------------------------------------------------

// | JuhePHP [ NO ZUO NO DIE ]

// +----------------------------------------------------------------------

// | Copyright (c) 2010-2015 http://juhe.cn All rights reserved.

// +----------------------------------------------------------------------

// | Author: Juhedata <info@juhe.cn-->

// +----------------------------------------------------------------------

   

//----------------------------------

// 基金财务数据调用示例代码 - 聚合数据

// 在线接口文档:http://www.juhe.cn/docs/28

//----------------------------------

   

header(&#39;Content-type:text/html;charset=utf-8&#39;);

   

   

//配置您申请的appkey

$appkey = "*********************";

   

   

   

   

//************1.主要财务指标************

$url = "http://web.juhe.cn:8080/fund/findata/main";

$params = array(

      "key" => $appkey,//APPKEY值

);

$paramstring = http_build_query($params);

$content = juhecurl($url,$paramstring);

$result = json_decode($content,true);

if($result){

    if($result[&#39;error_code&#39;]==&#39;0&#39;){

        print_r($result);

    }else{

        echo $result[&#39;error_code&#39;].":".$result[&#39;reason&#39;];

    }

}else{

    echo "请求失败";

}

//**************************************************

   

   

   

   

//************2.基金规模************

$url = "http://web.juhe.cn:8080/fund/findata/size";

$params = array(

      "key" => $appkey,//APPKEY值

);

$paramstring = http_build_query($params);

$content = juhecurl($url,$paramstring);

$result = json_decode($content,true);

if($result){

    if($result[&#39;error_code&#39;]==&#39;0&#39;){

        print_r($result);

    }else{

        echo $result[&#39;error_code&#39;].":".$result[&#39;reason&#39;];

    }

}else{

    echo "请求失败";

}

//**************************************************

   

   

   

   

//************3.资产配置************

$url = "http://web.juhe.cn:8080/fund/findata/config";

$params = array(

      "key" => $appkey,//APPKEY值

);

$paramstring = http_build_query($params);

$content = juhecurl($url,$paramstring);

$result = json_decode($content,true);

if($result){

    if($result[&#39;error_code&#39;]==&#39;0&#39;){

        print_r($result);

    }else{

        echo $result[&#39;error_code&#39;].":".$result[&#39;reason&#39;];

    }

}else{

    echo "请求失败";

}

//**************************************************

   

   

   

   

   

/**

 * 请求接口返回内容

 * @param  string $url [请求的URL地址]

 * @param  string $params [请求的参数]

 * @param  int $ipost [是否采用POST形式]

 * @return  string

 */

function juhecurl($url,$params=false,$ispost=0){

    $httpInfo = array();

    $ch = curl_init();

   

    curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );

    curl_setopt( $ch, CURLOPT_USERAGENT , &#39;JuheData&#39; );

    curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );

    curl_setopt( $ch, CURLOPT_TIMEOUT , 60);

    curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    if( $ispost )

    {

        curl_setopt( $ch , CURLOPT_POST , true );

        curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );

        curl_setopt( $ch , CURLOPT_URL , $url );

    }

    else

    {

        if($params){

            curl_setopt( $ch , CURLOPT_URL , $url.&#39;?&#39;.$params );

        }else{

            curl_setopt( $ch , CURLOPT_URL , $url);

        }

    }

    $response = curl_exec( $ch );

    if ($response === FALSE) {

        //echo "cURL Error: " . curl_error($ch);

        return false;

    }

    $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );

    $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );

    curl_close( $ch );

    return $response;

}

Nach dem Login kopieren


Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
2 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Repo: Wie man Teamkollegen wiederbelebt
4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Abenteuer: Wie man riesige Samen bekommt
3 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools

SublimeText3 Mac-Version

SublimeText3 Mac-Version

Codebearbeitungssoftware auf Gottesniveau (SublimeText3)