app inventor 2 POST - php

I want to integrate a webviewer component in an appinventor app.
I want the app to POST something to already prepared PHP script. I do not want to use GET. So PHP on server looks like:
<?php echo $_POST['value']; ?>
My appinventor block looks like:
This is NOT working. Any help appreciated.
Thanks.
EDIT: 2nd try. Thank you #YiWei.

add requestheaders:content-type:application/x-www-form-urlencoded and buildrequestData

the webviewer only can do GET
this should work:
using the web component, you get the result back in the Web.GotText event
see also the documentation

Related

Send a $_GET request with special characters in the HTTP header (escaping)

I'm trying to work on my new wordpress plugin, and I encountered an issue.
I'm setting a variable to contain something like this:
esc_html('likeit'.wp_generate_password(4))
And then - I want to call another function via GET, but it's sometimes breaking.
For example if I have: likeitA9&n, it will break at &.
Can you please tell me what's the best (and most secured) but simple way to handle this in my plugin?
Examples would be appreciated!
Thanks a lot!
P.S. - I did try to look at previous posts, but nothing that actually solved this :(
urlencode('likeit'.wp_generate_password(4));
or
rawurlencode('likeit'.wp_generate_password(4));

angular js with php integration

I used the code from http://angularjs.org/ (Wire up a Backend)
Here in project.js
angular.module('project', ['firebase']).
value('fbURL', 'https://angularjs-projects.firebaseio.com/').
factory('Projects', function(angularFireCollection, fbURL) {
return angularFireCollection(fbURL);
}).
config(function($routeProvider) {
I used this code in my web page. Instead of https://angularjs-projects.firebaseio.com/ url i want to use my url i.e http://test.com/test.php. But it didn't work.
Also i want to know in my php file in which format the out put should be?
Do you need to echo the content in php file or use the return command? Please give suggestion. I have searched a lot. I couldn't find the solution.
I think in firebase url https://angularjs-projects.firebaseio.com/ they are returning the response from their back-end service. That is why it didn't worked for you even if you changed the URL.
And answer to your second question;
If you make a call to your back-end service its better to have a json response style from your PHP and you don't have to use any return command for that. Instead you should echo your contents.
For example in your PHP file if you are getting the results as an array you can give back the response to the angular application as;
echo json_encode($result_array);
Hope it helps.
I think you should separate backend and frontend and treat them as two separated application. Both apps should communicate with each other by sending ajax request (front) and respone data in json format (backend). In my opinion it's the best way to handle this.

execute some function in some php file on another server(apache) and get the returned value

I want to access some function written in some php file on another server and receive the input, I have access to those server files so that I can change them for proper configuration, I have all the privilleges to do so, can anybody please guide me how can I do it, thank you
$result = file_get_contents("http://some.server/out.php");
and in this out.php
<?php
include 'some.php';
function();
I think you can implement web service or an api, and the output could be in xml or json read the content and use it on your website.
It is just Facebook graph API using URL
https://graph.facebook.com/Pepsi
The above link will fetch information regarding Facebook page of Pepsi.

Scrape a website (javascript website) using php

I am trying to scrape a website (believe it is in JavaScript) using a simple PHP script. I am a beginner so any help would be greatly appreciated. The URL of the webpage is:
http://www.indiainfoline.com/Markets/Company/Fundamentals/Balance-Sheet/Yes-Bank-Ltd/532648
So here for example I would like to pass the name of company (Yes-Bank-Ltd) and code (532648) in get_file_contents. Not sure on how to do it so can somebody please help.
Thanks,
Nidhi
Why aren't you just not append the string of the company and code in the url. Here is an idea that you fill up an array of company and code (need to be the same size) and then you loop them to scrape the data you want.
for($i=0;$i<count($listOfCie);$i++)
{
$cie = $listOfCie[$i];
$code = $listOfCode[$i];
$urlToScrape = "http://www.indiainfoline.com/Markets/Company/Fundamentals/Balance-Sheet/" . $cie . "/" . $code
//... = get_file_contents($urlToScrape....
}
Use the data.html table in YQL! http://developer.yahoo.com/yql/console
The simplest way to scrape a site in PHP is to use curl (http://php.net/manual/en/book.curl.php)
For some examples look at http://php.net/manual/en/curl.examples-basic.php or google :)
If the website relies on javascript though it's going to be difficult to get the data you want. You might look at a "headless browser" like http://phantomjs.org/

How to access var in PHP

I'm using selenium-rc with php. I want to show in my test the value of CLASSNAME. How can i present the var? I tried to do $this['drivers']['CLASSNAME'] but this is not working for me.
(This is from the debug)
Thank you!
Looks like it should be:
$this->drivers[0]->CLASSNAME

Categories