how to query multiple endpoints with curl on sdata web serivce - php

I am trying make a request query to Sage sdata web service to the following endpoints tradingActivites and receipts as nothing is obvious on these docs
I have this so far localhost:5493/sdata/accounts50/GCRM/-/tradingActivities?where=accountReference eq "1200" &format=json that gives me all the transactions of this account but I also need the information from receipts endpoint as well.
Is it better to do two curl requests or what would be the correct syntax for querying this type of web service in the URL.
Thank you for reading this any help would be appreciated.

You would need to do two curl requests to get the data you need and then do whatever matching of data you need in PHP.
This is based off the information I have unless you can look through the docs and get a method that provides all the data you need.

Related

Safely connecting to Cloudant using AngularJS (and possibly PHP)

I built a very simple AngularJS Shop App that creates product orders.
As of now, the app just sends orders via email to the customer and retailer using PHP, but I thought it might be good to learn a bit how to use databases, and store/retrieve this orders (which are arrays) into a Cloudant.
But then I realized that to connect to the Cloudant service, the call looks like this:
https://{username}:{password}#username.cloudant.com/DB
I assume this is not very safe at all, as the call and credentials would be visible for anyone.
Also, in the App there's no need at all for anyone to have an account or login, which would partially help with security.
As I have 0 experience with Node or any other backend system, I'm wondering: Is it possible to make secure calls to a Cloudant service using only AngularJS (or PHP to store the sensitive values)?
I've read a bit about the one db per user, but it doesn't seem to help in my case, where I need one single DB to store all my orders.
Any tips would be highly appreciated.
If you need to expose your credentials in your API calls, you better not do them from the front-end. If you're using Angular and PHP, the easiest way to hide your auth info from the public would be the following:
Create a PHP file and move your API code to the back-end.
This will be a bit of work, but in the end the service login should happen on the server. This file should receive requests from the client and transmit them to the remote service, then return its response to the client.
Use AJAX on the front-end to make calls to the above PHP file, and proceed displaying its response to the user like you would handle an API response.
This way your API credentials aren't exposed to anyone checking your page's HTML source and you can keep most of your front-end logic the way you have it set up already.
As #ppajer said, I strongly discourage to use AngularJS to do what you want to do. Leave it on the back-end and use ajax to make the calls. Take a look at this repo, it may help you: https://github.com/osipov/bluemix-cloudant-php-sample

Rest API feed access options

There is a REST API which I want to access and use the GET Method to get the data from xml and store it into MySQL. I thought to give PHP curl a try to request the data from API and setup a cronjob for the script run automatically on the given days. The problem is that the feed is not allowed to be accessed through browser. What other ways are there to get the data and store into mysql?
I used httpful client by nate good to solve this issue. Hope it helps other as well.

Android : Confused/Lost with Call a PHP webservice with Send & Receive

From my android app, I want to call php web services. At times, I just need some data from php, sometime get data based on some parameter passed. I prefer to use RAW Api like HttpClient. I also plan to use mySql DB.
To call php web services, I got references from http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/, and http://www.anddev.org/doing_http_post_with_android-t492.html, http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
I am STUCK at :
For eg: I pass 2 parameters with my url "http://......php?src=SOURCE&dest=DEST
REsult - Directions from SOURCE to DEST (at times result may be an array of strings, items, etc)
How to do send & receive data back in single request ?
How to write php for the same ?
Can the above accomplished using raw aPI or JSon or ksoap is required ? I have read that instead of using Jsoan or Soap, raw is the best approach.
Kindly help me to solve the confusion and proceed ahead wit hthe application.
Any help is highly appreciated.
Thanks
Yes,
alfasin, thru ur post and other sites I got things properly working.

Getting xml data and writing to db from external source

I have spent the past three days researching this... but Im still stuck.
I have a service provider that offers me a REST api. I need to:
Get the data from his api
Assign the data to variables in php
Write the data to my localhost sql database.
All that's required is the API KEY which has been provided to me.
Please could someone explain to me what method I should use to call and store the data in php.
Writing to the Database and handling the data once in php format is not a problem.
Thanks in advance
Since you want to consume a webservice you would have to make HTTP request using PHP.
There is many ways to do that but the most used(IMHO) is cURL. cURL function would allow you to easily make HTTP request and consume data from the webservice.

How could I make a PHP webservice to receive data from third parties?

I'm creating a webservice in which remote sites can send data to a PHP-based webservice. However, I'm struggling to come up with the best way of handling the incoming data.
The data will be in the form of shopping basket contents, so might include product name, price, ID, date, customer etc. There will be one line of data for each product in the basket, so there could be 20-30 lines for some customers.
Would sending the data to the webservice via GET be sensible? Is there a better option you can think of? Any input is greatly appreciated.
Thanks!
Probably not a great idea to send via get. I'd generate the basket as XML or JSON, then post it to the service. You can then write back a response on XML or JSON saying whether or not the call was successful.
A nice introduction to a RESTful API with PHP is here. I find it goes a bit overboard in some places, you can do the same with a little less code but it is nonetheless a good guide.
If the request is going to be making a change, I would not use GET. It would break GET's safety. Here's the HTTP spec on safe methods: RFC 2616.
I would recommend you look towards a REST architecture where it seems like a POST or possibly a PUT request should be used.

Categories