File_get_contents () unanswered - php

I am trying to call a webservice that basically looks like this:'Some description'


So this is how I call this web service:

$endpoint = "'Some description'";

    $opts = array('http' =>
                    'method' => 'GET',
                    'header'  => 'Content-type: application/xml'

    $context  = stream_context_create( $opts );

    $result = file_get_contents( $endpoint, false, $context );
    $xml_result = simplexml_load_string( $result );
    echo $xml_result->success;


So I got nothing, xml_result is empty. And here's the fun part - when I remove the white space from the description:'Somedescription'


Everything is fine, I got a response from the web service. Also tried to call webservice with chrome rest client with space in description and everything is fine, I have an answer. So this leads me to some kind of PHP issue here with spaces in the web service. Please, help!




leads to




source to share

1 answer

This is not a valid URL, spaces must be escaped:'Some%20description'


You might want to take a look at How to properly encode a URL in PHP? ...



All Articles