How do i access my database from Spotify apps - php

Okey so I am building a spotify app and I will need access to my MySQL database in this app both getting and inserting data to it, now spotify don't support PHP witch I would normally use for this so how do I work around this? I have no idea how to do this without using PHP.

Spotify API uses JavaScript and you can use for example jQuery framework with it. Just save
jquery.js to your addon-folder and include it in your script. Then you can use $.post() and others to save/retrieve data from your external server.

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

How to store Android app data on server (Google drive or json)

I am working on an Android app where the user fills a form and submits it. I want to know which technique to use to store the data. I want to later process this stored data to form reports. Please suggest me the best way to store data and later to produce report.
The form initially will contain one dropbox, date, radio button and edit text.
I found few options below but dont knw how to proceed:
Using JSON
Using Google cloud
I tried code at below link:
http://androidexample.com/How_To_Make_HTTP_POST_Request_To_Server_-_Android_Example/index.php?view=article_discription&aid=64&aaid=89
But dont know how to run the program as it needs serverside php script. I have XAMPP installed on my machine with Apache server running. I can run normal php code but dont know how to make that php code work with my android app.
I am new to server side data handling
Thank you very much in advance. Please help
since you're working with xampp.you can access your localhost from your android emulator using the ip 10.0.2.2/
you will need to use the AsyncTask class and a JSON parser to send your data to your php script.The JSONparser class will remain constant for most of your whole app. You will only have to change the code in your AsyncTask class depending on what data you want to send and the location(php file ie 10.0.2.2/your_file.php or yourdomainname.com/your_file.php) to process the data.
If you don't want to work on server scripting and requires a simple data storage to the cloud then you can try using Parse
Basically Parse provides you with a library that your app can use to pass values to the server Parse is managing.

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.

How to Access REST Service in Jax-RS using PHP

I Developed a REST Service in Jax-RS, and I have some functions that use the POST method, like:
Auth_User()
Get_List()
Insert_Data(id,name,data)
I need to access these functions using PHP cURL. What I basically need is to work the functions from the PHP files, so that my REST Service can work like Facebook App development.
how can I do this using cURL?
You can use the CURL library with it's wide range of options to perform GET/POST/HEAD etc. requests that you would need to communicate with your REST server.
As for parsing data, you would have to take a look at either json_decode() if you get json objects back, or e.g. SimpleXml if you need to parse it as XML.
See this site here for a decent example of querying the yahoo REST api in php/curl:
http://developer.yahoo.com/php/tutorials/water_bug_tutorial-making_rest_request.html
There is no such thing as a REST server. The question you are asking is "How do I make an HTTP request from PHP?" What technology the server is implemented with is absolutely irrelevant. At least it should be!

Connecting Php with javascript

I am trying to make a plugin that people can place on their site to generate a form. I dont want to use an iframe to display the form but use javascript to generate it.
The problem is how do i connect the javascript and php together. My site is programmed in PHP.
Your getting a liite mixed up, I think.
PHP runs on your server. This is the place where you fetch data from the database and create some form of html-response.
Javascript runs in the browser. It can't directly talk to your database.
iframe is a special html-element: Therfore it is passive and can't do anything like creating a form.
You have two ways:
Create a PHP script which handles everything through plain HTTP-Requests. This is the "old school" way and requires a lot of page-reloading.
Write most of the logic in javascript and let it communicate to PHP/your database through AJAX. In this case. Have a look at jQuery which makes AJAX-requests (and a lot of other things) very easy.
One issue you will be faced with is 'Cross site Scripting' with Javascript / AJAX.
You can read up on it a bit here:
http://snook.ca/archives/javascript/cross_domain_aj
Also, thinking your process through, you will need sufficient javascript code to create a 'widget' on any place, and have a way to communicate BACK to your server (keep in mind PHP only runs local on your machine, so it cannot be used remotely in your javascript).
You will probably need to build a JSON API (google / stack search this if needed).
And enable communication from your JAVASCRIPT to the API (don't think of it as to PHP, even tho php will be your API server side language).
Here is an example of a PHP JSON API (on youtube too):
http://www.youtube.com/watch?v=F5pXxS0y4bg
If you put PHP into JavaScript and someone implements this, PHP will compile on their server. So you just can't. You just need to put the form in your plugin.

Categories