Title: REST API HELP Post by: BTCIndia on August 05, 2016, 05:09:37 PM Dear All,
Im Trying to hit a Get Request from my https server but it always Return NULL Please help, https://tierion.com/docs/dataapi#api-create-datastore Code: <?php Here is my potato in advance... :) http://3.bp.blogspot.com/-k6mmw9BbX4E/VXtPzM22rgI/AAAAAAAAAp0/axlLjiF-QKI/s1600/potato.gif Title: Re: Tierion REST API HELP Post by: achow101 on August 05, 2016, 05:26:37 PM Since it is a GET request, you don't need this line which is for post:
Code: curl_setopt($curl, CURLOPT_POST, true); Furthermore, you are authenticating incorrectly. The authentication stuff should be in the headers, not in the body of the request. Instead of Code: $curl_post_data = array( Code: curl_setopt($ch, CURLOPT_HTTPHEADER, array( Note, I don't have experience with Tierion's data api. I just read the documentation you linked to, I highly suggest that you give that a read and fully understand how the API works, and how HTTP Requests work. Title: Re: Tierion REST API HELP Post by: BTCIndia on August 08, 2016, 09:04:46 AM Since it is a GET request, you don't need this line which is for post: Code: curl_setopt($curl, CURLOPT_POST, true); Furthermore, you are authenticating incorrectly. The authentication stuff should be in the headers, not in the body of the request. Instead of Code: $curl_post_data = array( Code: curl_setopt($ch, CURLOPT_HTTPHEADER, array( Note, I don't have experience with Tierion's data api. I just read the documentation you linked to, I highly suggest that you give that a read and fully understand how the API works, and how HTTP Requests work. This is first time, I'm working on API and its really painful. I'd really appreciate if you can write code to authenticate. I'm sure, I can write GET, POST command thereafter. Title: Re: Tierion REST API HELP Post by: achow101 on August 08, 2016, 01:12:02 PM This is first time, I'm working on API and its really painful. I'd really appreciate if you can write code to authenticate. I'm sure, I can write GET, POST command thereafter. The code is right there. Just look at my earlier post. The first two code blocks are the code that you should remove from your script. The last block is what you should add right afterCode: $curl = curl_init($service_url); Title: Re: Tierion REST API HELP Post by: BTCIndia on August 10, 2016, 11:13:34 AM This is first time, I'm working on API and its really painful. I'd really appreciate if you can write code to authenticate. I'm sure, I can write GET, POST command thereafter. The code is right there. Just look at my earlier post. The first two code blocks are the code that you should remove from your script. The last block is what you should add right afterCode: $curl = curl_init($service_url); Thank you Knight! |