I have a properly coded HTML page that I can display in my app.
The file is embedded locally inside the app, but it pulls in data from an API.
It is a Rest API that works with PHP.
So my question now is - is it possible to have NSString inject it's value into the php file so that it can display the required result, or are PHP and Objective-c not designed to do that??
If you are looking to actually parse and execute PHP in your iOS app, I am afraid you are probably out of luck.
If you simply want to dynamically update certain elements on a static HTML page and leverage a PHP service to do it, your best bet is probably to use javascript and AJAX to put the dynamic content from the service.
Alternatively, you can treat the HTML file like a template, make a call to the PHP service to get the dynamic content; merge that content into the template and display the template.
I guess what is most appropriate in your case, will ultimately depend on your desired user experience.
Related
I can't seem to find any other info on this topic anywhere on the interwebz.
SharePoint 365 seems so powerful, looks like an awesome solution for a whole bunch of business IT requirements.
But everything is in ASP and XML, but all my data is inside an external MySQL server, accessible through PHP pages which process and spit out JSON objects. This has worked nice and tidy for all my other apps so far.
How can I get my SharePoint site (which is basically HTML CSS and JavaScript, right?) to hit my PHP server (with HTTP GET or POST) to access my JSON data (and then process and display it however I like)?
I know AJAX can't hit external servers, so on my SharePoint site I'd need something equivalent to cURL perhaps... but with the functionality of AJAX?
Another possibility I'd avoid would be to create some kind of middle-man page/file/app in SharePoint which can process the data locally via AJAX, and send/receive data to/from the external PHP server. But this would all be in C# or ASP, ughhh surely there's an easier way?
EDIT :
Came across this post regarding XML content, the best answer was to "create a custom .NET assembly" to parse the XML... I can't believe SharePoint with all its awesomeness wouldn't be able to handle external JSON content??
You are right that SharePoint at it's heart is just ASP.net engine rendering HTML, JS and CSS down to the browser. For SP to access your data, you would need to expose the MySQL data via a REST service. This could be written in any language since it is a service. It does not need to be C#, .net or ASP as all SP is doing is calling your endpoint and receiving the json data. So no reason you could not use PHP for this.
Once you have the service, you can create a javascript file to call it using jQuery and the $.ajax() or getJSON() method to get the data. You render the data onto the SharePoint page by adding the Script Webpart in the proper location. Once added, click the Edit Snippet link on the script webpart and insert html with a reference to script file and a div to write the results. There are many examples of how to do this type of request and parse the data on the web as it is not something specific to SharePoint. Place the javascript file in the SharePoint site. I typically put it in a custom folder in the _catalogs/masterpage library.
If you just need to display this external data on one page along side your SP data, like in a dashboard, this solution will work. If the external data needs to interact with the SP data or you need to place it in multiple locations, then you may want to look into building a SharePoint App and you can use PHP to do this. Here is a link to a sample project on GitHub. https://github.com/OfficeDev/PHP-App-for-SharePoint
I have a website with a jQuery UI navigation, and I've got ajax working to dynamically change content between html files. I'm basically just replacing the contents of certain div ids with the contents of other div ids.
This still requires numerous HTML files and I was wondering if there was a way to have a single html file and load content into the main page from it instead? What about an xml file?
Thanks for the tips and advice about best practices and possible solutions.
Using HTML:
Template Views-- Using this method you create separate html files for each piece of your site that you want to be able to load dynamically. This is More efficient, but it means you need to be able to manage your files properly.
Single View-- This method involves loading the entire page again, and extracting out the desired data in order to update the page. This is not very elegant or efficient, and I don't recommend it.
Using XML/JSON
This usually involves making ajax requests for data and using it to render the page on the client.
XML/JSON is typically more lightweight than html markup which decreases the amount of cpu time and bandwidth used on your server, however it does require that your users have computers that can handle doing some DOM manipulation.
This also requires that you have a good way of organizing your ajax modules. A pattern that I use looks like this.
$PROJ_DIR/ajax/{MODULENAME}.php
Then a module with the name calendar might accept an actions like, getYears, getTerms, setCurrTerm.
And within that script you switch thought the action to output the correct data, and or make the correct DB changes.
Multiple html files for views isn't a bad thing if you've structured it nicely.
I'm a C++ programmer and I'm new to web development.
I need to figure out how I can log/dump the html of a dynamic 3rd party website to a static html file on my computer, every second?
The dynamic webpage refreshes every second and updates a html table with latest price info. I would like a static snapshot of this table (or the whole html page) to be saved to disk every second. That way I can parse the file with my own program and add the updated price info to a database.
How do I do this?
If I cant do it this way, is there a way to eves drop (and log) on the the post/get messages and replies the dynamic webpage sends?
Look into the cURL Library. I believe Scraping the content from a website, and doing your processing/business logic, then inserting or updating your database would be the most efficient way to do it, rather than saving the files contents to disk.
Alternatively, file_get_contents() works pretty well assuming you have allow_url_fopen enabled.
It would be easy to do with Selenium Webdriver. You can use Selenium to create a browser object with a method, getPageSource, that pulls the entire HTML from the page, but it doesn't seem there are any C++ bindings for Selenium. If it's convenient to use Ruby, Python, or Java as part of your application, just in order to open up a browser or headless browser and pull the data, then you should be able to set up a web service or a local file to transfer that data back into your C++ application.
Web automation from C++ addresses the challenge of no Selenium C++ bindings
Or, alternately you could write your own C++ bindings for Selenium (probably more difficult)
However -- for simply pulling the HTML, you may not need Selenium if one of Dan's answers above will work.
Hej someone else.
insed of running there page every second to record there data so you can have a updated
view of there prices, why not call there web service directly (the one there ajax call makes)
Gl
I am Creating a web application that will get homework from schools website.
I have been creating rss feeds for the website using dapper Creating an rss feed converting that into html and then putting that into an Iframe on my website.
I think there has to be a better way to do this.
I don't care what language this would be done in but i would prefer to do it client-side with php or javascript.
I'm intermidiete level php and not so good at java script.
If you could provide detailed explanation with some code that would be great.
also I have legal permission from my school which will be the first for this to go live to get the homework.
I'm assuming you are about create an php application to retrieve the rss from external site (which already have a specific url). Well, i think its better to build a public API first at the source app/external site, to get more multimedia support.
But if you're have no problem with parsing an xml format into html directly, then you can use cURL instead iFrame(or if you didnt have cURL installed in your php, you can modify lil bit and use my Proxy Library,a PHP class which enables you to make call to internal and external site with general HTTP request by opening a socket connection to the remote host, originally writen as Codeigniter Library.)
That way, it will be easier to presenting a html view/page rather than proccess it via iFrame.
I am just starting out with Haxe development, and wanted to give the PHP side a go, but am already a little confused.
What is the best way to save some form data to XML files in a folder on a server with Haxe compiled to PHP?
Well you can do it two ways.
Make the website form in haxe, which includes:
making proper .htaccess file for the project on server,
writting a Main class (that htaccess will be pointing) which will take a request,
and return either a form html document or will take the data from the form...
then put that data into xml format,
and finally put that data into a file.
Here are Api files you should have a look at:
File methods for writting to a file
Web class that will get request data and fire up proper class and function, getURI, getMethod, getParams
Template class for generating simple html / very simple
Depending on complexity of xml you may want to use a specialized class
And the second way is almost the same, but you only compile to one file.
And in your html form, you put your action link to the php filed that came out of compilation...