Reputation: 692
I'm a bit of a noob at some of this so I was wondering if someone could help with what I hope is a simple question.
I've developed a Yahoo Pipe that takes as Input the name of a Label(s). This then should run the yahoo pipe to generate the output.
Below is a snippet of code that is generated when I run the the Yahoo Pipe from the Yahoo Pipes page.
Now my question is I want to run this pipe from my own site and get the user to Input the labels they want rather than having them leave the site and go to the Yahoo Pipes page.
<script src="http://l.yimg.com/a/i/us/pps/listbadge_1.4.js">{"pipe_id":"6c3a35f3d8e3cdb8ef270a3565d64ca3","_btype":"list","pipe_params":{"tags":"Cooking Beef Chicken"},"width":"600","height":"500"}</script>
I'd like to have a simple Form that the user fills out and for the code to generate the above script code from their input and execute.
I hope I've explained this as it's a little confusing.
To sum up, how do I get input from a user on a web page about which Labels they want to run the pipe against and for it to generate the correct code and execute.
Upvotes: 0
Views: 472
Reputation: 646
It's a three part trick if you use a server side script
Information is sent from a regular form back to the page it comes from and that is extracted from the url like so
enter <?php $userInput = $_GET["userInput"]); ?>here
Now the userInput can be written into a javascript src URL that makes the cross domain call to the pipe.
enter <script src="http://pipes.yahoo.com/pipes/pipe.run?_id=050fc8ccfefd18420680a86ebf4bf80e&_render=json&_callback=cbfunc&town=<?php echo $userInput; ?>"></script> here
When the pipe returns the data it wraps a 'callback' tag around it, in this case called cbfunc and this is used to trigger a javascript routine in the page head that extracts data the JSON string for you to do what you want with it.
enter function cbfunc(data){
var data = (data.value.items[0].content)
} here
You can see a working example of this in action at http://bishop-test.appspot.com/ when you click on the map search. This link is also helpful for examaning the JSON output http://braincast.nl/samples/jsoneditor/
Upvotes: 1