User Tools

Site Tools


developers:api:client:requests

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
developers:api:client:requests [2014/11/16 06:47]
Jaco van Wyk [PHP (Example)]
developers:api:client:requests [2014/11/16 06:52]
Jaco van Wyk [Examples]
Line 36: Line 36:
  
 <code php> <code php>
-       $service_url = '​http://​api.snapbill.com/​v1/​example';​ +<?php 
-       ​$curl = curl_init($service_url);​ + 
-       ​$curl_post_data = array( +$service_url = '​http://​api.snapbill.com/​v1/​example';​ 
-            "​client_xid"​ => '​T:​SA',​ +$curl = curl_init($service_url);​ 
-            "email_address" => '​email@example.com',​ +$curl_post_data = array( 
-            ); +     ​"​client_xid"​ => '​T:​SA',​ 
-       ​curl_setopt($curl,​ CURLOPT_RETURNTRANSFER,​ true); +     ​"email" => '​email@example.com',​ 
-       ​curl_setopt($curl,​ CURLOPT_POST,​ true); +     ​); 
-       ​curl_setopt($curl,​ CURLOPT_POSTFIELDS,​ $curl_post_data);​ +curl_setopt($curl,​ CURLOPT_RETURNTRANSFER,​ true); 
-       ​$curl_response = curl_exec($curl);​ +curl_setopt($curl,​ CURLOPT_POST,​ true); 
-       ​curl_close($curl);​ +curl_setopt($curl,​ CURLOPT_POSTFIELDS,​ $curl_post_data);​ 
-  +$curl_response = curl_exec($curl);​ 
-       ​$xml = new SimpleXMLElement($curl_response);</​code>​+curl_close($curl);​ 
 + 
 +$xml = new SimpleXMLElement($curl_response);</​code>​
                
 We execute the request and capture the response. **Health warning:** by default curl will echo the response, if you want to parse it then you will need to use the CURLOPT_RETURNTRANSFER flag to have curl return the response rather than a boolean indication of success. We execute the request and capture the response. **Health warning:** by default curl will echo the response, if you want to parse it then you will need to use the CURLOPT_RETURNTRANSFER flag to have curl return the response rather than a boolean indication of success.
developers/api/client/requests.txt · Last modified: 2014/11/16 06:52 by Jaco van Wyk