Submit a XML request in PHP -
I am trying to get information from an API. I want to be able to get the "Location:" property from the API response and would like to capture it as a variable in PHP.
Here is an erosion from API docs so that you can know what I'm talking about:
Read the person's portrait address from the request of this example It shows how to read a description of the picture for a tree person.
XML Request
Receive / Forums / Trees / Individuals / KWWM-5R1 / Portrait Accept: Application / X-FS-V1 + Xml
Authority: Carrier YOUR_ACCESS_TOKEN_HERE
FeedbackHTTP / 1.1 307 Temp Redirection
Transfer-Encoding: Chunked
Cash-Control: No-Transform, Sure-Modified , Max-age = 0
Content Type: Application / X-FS-V1 + Xml / Variation: Accept-Encoding / Variation: Sweep Accept-Language, Accept-Encoding, Expect Location: / Domain / Path / Per / Image
X-Processing Time: 1
Content Location: / Platform / Tree / Individuals / PPPP-PPP / Portraits
To capture the return and location for Lee: The value (path to the image) as a PHP variable so I call it as an image source Can be used.
I have tried to use curl from another help site but it does not return anything (not even error)
$ ch = curl_init (); Curl_setopt_array ($ ch, array (// set url, timeout, encoding header etc. CURLOPT_URL = & gt; 'https://sandbox.familysearch.org/platform/tree/persons/KWWM-5R1/portrait, // .)); Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('authorization: carrier'. $ _SESSION ['FS-session'], 'Accept: application / X-FS-V1 + xml',)); $ Respons = curl_exec ($ ch); $ Info = curl_getinfo ($ ch);
I apologize for asking too much help, but I am very new to it and trying to understand it all night.
Do you mean you want to get the answer headers for just one request? You can use it:
Comments
Post a Comment