1

I want to get 2 different sets of data using 2 different apis and display it on the same page. The first dataset displays fine however when doing the second request i get the error:

Warning: Constant already defined in C:\xampp\htdocs\exempel\biblo\httpful.phar on line 7

Fatal error: Cannot declare class Httpful\Bootstrap, because the name is already in use in phar://C:/xampp/htdocs/exempel/biblo/httpful.phar/Httpful/Bootstrap.php on line 11

What am i doing wrong? Is it possible to send 2 requests like this or do i have to solve it some other way?

I am using the standard httpful.phar, The code used here is just example code for my real project however the problem is the same, that i cannot do 2 requests. If any more information is needed i am happy to provide it!

Thanks and have a good day!

Code bellow:

<?php
    include('../biblo/httpful.phar');

    $url = "http://api.scb.se/OV0104/v1/doris/sv/ssd/START/MI/MI0307/MI0307T1";

    $postKod =  '{  "query":[
                            {
                                "code":"ContentsCode",
                                "selection":{
                                    "filter":"item",
                                    "values":[
                                        "000000XV",
                                        "000000VA"
                                    ]
                                }
                            },
                            {
                                "code":"Tid",
                                "selection":{
                                    "filter":"item",
                                    "values":[
                                        "2015"
                                    ]
                                }
                            }
                        ],
                        "response":{
                            "format": "px"
                        }
                    }'; 


    $response = \Httpful\Request::post( $url )
        ->body( $postKod )
        ->send();

    echo $response;

?>

<?php
    include('../biblo/httpful.phar');

    $url = "http://api.scb.se/OV0104/v1/doris/sv/ssd/START/MI/MI0307/MI0307T1";
    
    $postKod ='{    "query":[
        {
            "code":"ContentsCode",
            "selection":{
                "filter":"item",
                "values":[
                    "000000XV",
                    "000000VA"
                ]
            }
        },
        {
            "code":"Tid",
            "selection":{
                "filter":"item",
                "values":[
                    "2015"
                ]
            }
        }
    ],
    "response":{
        "format": "px"
    }
}'; 

    $response2 = \Httpful\Request::post( $url )
        ->body( $postKod )
        ->send();


    echo $response2;

?>

Map structure

error message

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24

0 Answers0