I'd like to preface this by saying that I'm feeling a bit overwhelmed at a summer internship, it's a lot of new technologies and concepts I've never used before and finding good resources to explain these things and not just regurgitate situational tutorials are very scarce. Particularly I'd like to talk about ASP.NET.
What I currently have is a simple webpage made using ASP.NET in visual studio. My general task is to access a database, get the info from the database, turn the data into JSON, and send that data to a python script which will then parse the JSON and do stuff with it, etc.
I am able to get as far as making the JSON object. I can get the user to download the json object as a file, but what I really want to do is just pass it through the network by accessing my web site from the python script using urllib2. This is where I have become completely lost. There are so many terms I've never heard of before, things like services, web APIs, controllers, routing and all these things I've spent hours digging around in and following basic tutorials but still cannot find a firm grasp on the concepts let alone how to accomplish it in a practical manner.
To be completely clear here are my goals:
Send 5 parameters usingurllib2 in python to my asp.net site
use these parameters to query the database and get a json object (COMPLETE)
return the json to the python script
I have no idea how to set up a "service" or how to even go about doing so. I know that I have to attach it to my website somehow but I'm not sure. Any suggestions or good resources would be much appreciated. I'm just looking for some direction and advice on how to go about accomplishing #1 and #3 on my list.
Thank you for taking the time to read through my post!
For part one you could do this:
import urllib2
response = urllib2.urlopen('http://mysite.io?paramOne=ValueOne/')
Now the response object will have your JSON so you can do this:
json = response.read()
urllib2 has a nice way of preparing URL parameters which you might want to look into.
Related
Okay guys, here's the deal. I'm a total C# beginner but I've been advised to learn it. I'm desperate to get a working Bitcoin value grabber going - so that I can record the values to a text file. Another thing is that the value must be from MtGox, either their API or their homepage.
I've spent a while dealing with HTTP requests and JSON decoding (grrr...) but I don't see the point in me spending so much time on my learning code when I'm sure there is someone else out there who can just help me to write it.
Does anyone think they might be able to help with this? Just a couple of lines to pull the last Bitcoin value from MtGox.
Any contributions are much appreciated.
Will.
EDIT:
var json = WebClient.DownloadString("http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast");
string valueOriginal = Convert.ToString(json);
That is all I needed to write. Wow. Thanks for the help though, Oliver.
This is a Q&A site, so don't expect other's to write your code for you.
You can access their API using any language that supports HTTP calls.
Here's a great document to get you started:
MtGOX api docs
This is a judgement call, but it sounds like you're new to programming in general. Don't commit yourself to a language. Always use the best tool for the job. I'd suggest using something a bit more "web friendly" for this sort of work. NodeJS would make this much easier for you as it understands the JSON returned from their API nativly, without using all sorts of wrappers and instances of the WebClient class or HttpResponseMessages as you do in .NET. Also consider the purpose of writing the data to a text file. What is going to consume that data? It's possible that you can skip the file and just interact with the down-level consumer directally.
What format needs to be in the data file? If you can save it in JSON, you could do this in C#
using System.Net;
//...
WebClient Client = new WebClient ();
Client.DownloadFile("https://mtgox.com/api/1/BTCUSD/ticker", #"C:\folder\results.json");
Good evening/morning everyone,
before posting this issue, i've been sending my objects with a traditional way from the client side ( aspx page ) to a WCF data service, the approch i've been using was to convert all attributes to a string and send them after joining them, and in the server side i split the string chain and i construct my object and store it. now by working i found that this method is no longer udapted to what i'm planing to do and it will take me much time. so i've decided to find a way of serializing my xpo objects and send them to the service. been browsing google before coming up to SOF but i didnt find a good tutorial for someone not much familiar with serialization mechanism.
please give me some track to a solution which will reduce lot of time.
i think its a good point to descibe the architecture of my project:
i have a asp web application which contains some pages, and in the server side i have a wcf data service(5.0) which contains all my methods, i'm using XPO as a ORM and all my objects inherit from xpobject.
Thank you in advance and by the way i want to thank the mods/admins/members of SOF for their work helping dummies/intermediate and even experts.
From a performance perspective, it is not recommended to serialize/deserialize the object graph with XPO. Instead you should either serialize the datastore or serialize the object layer.
That said, if you need to serialize objects for import/export, have a look at the eXpand module.
As with all things DevExpress, the best place to ask questions is the support centre.
Been looking around for the last few days trying to figure out what the best route is. I am fairly new to ASP.Net so I am in need of a little assistance.
I like the idea of using Master Pages as it will make making changes to the template a lot easier! But I am running into some problems. I will just list them below and see where we can go, maybe this will help some other newbies like myself.
Dynamic Menu:
I am trying to create a menu system that will show certain links depending on the users role. This is simple enough until I just want the link to perform some functions and thats it. So I dont want it to postback or anything. So my next step was to try to use jQuery as I would with my php development. Problem is I cant seem to get my jQUery to call the master page code behind function. I've gone through all the tutorials I could find with WebMethods but just keep getting an error to the like of This type of page is not served.
General Classes:
In PHP sometimes I would have the need to just have some General classes that pertained to a specific area of the application. I would just use these to hold all the function I may need to call from jQuery. Is there something like that in ASP.Net? I tried just adding a class but again couldn't call it from jQuery. Is this something Web Services would be good at? I am still trying to understand their full use. Seems like we could use Web Services as a buffer between the client and the back end classes.
I look forward to any pointers or tips!
Oded and jrummell made it very clear I should probably start with ASP.NET MVC first. It will most likely be an easier road for me moving from php.
I have been looking around for hours trying to find a clear simple solution to my question and have yet to find a good answer. I am trying to do a URL request in flash to my NOPCommerce site. I want to pass a GET value to the my .cs file which i'll then use that value to grab specific information and return it back to flash. How would I set up the C# or asp.net side of things? If anyone could give me an example of what I am looking for I would greatly appreciate it.
I don't know if I am supposed to use a .aspx, .cs or .ascx file.
Thanks,
Brennan
I found it to be extremely simple with web services in as3. Here is a link to see what I mean
As3 Web Services
Use the HttpWebRequest class to GET the variables, do the magic and return a result by invoking the HttpWebRequest again.
Examples and usage here:
http://www.csharp-station.com/HowTo/HttpWebFetch.aspx
You have a few options for server-side communication with flash.
Flash remoting. This is the most popular because it's the most performant, but not the easiest to understand at first glance. It transfers data in a binary format. Available libraries are Weborb and Fluorine.
Web Services as mentioned in a previous post.
Ajax/JSON. I think with Flash Player 11.3, JSON decoding is native in the player now.
Straight up http request.
Sockets (not recommended for beginners)
To answer your question as you asked it, though, for all but #4, you'd be using a CS file to retrieve your data. For #4, you'd most likely be using an .aspx page, but it could be a combination of .aspx and .ascx files.
My recommendation is that you do some research on each of these methods to decide what would work best with your development environment, required level of security, and project. Then, ask specific questions about each method as necessary.
Good Luck!
Recently I have been thinking combining C# applications with a website, so that we can run multiple threads in C# and complete more tasks in the time it would take PHP would to do 1.
Most of us know that PHP Runs on a single thread and therefor we cant do multiple actions at the same time
But it would be nice if we can do something like:
$SharpEntity = new CSharpExecute();
$SharpEntity->add("downloader.class http://server.com/file.ext");
$SharpEntity->add("downloader.class http://server.com/file2.ext");
$SharpEntity->add("downloader.class http://server.com/file3.ext");
$SharpEntity->initialize();
while($SharpEntity->completed === false)
{
$SharpEntity->Update();
}
echo 'Files Grabbed';
This is just a basic example but would it actually be possible to do such a thing and if so, how can you do this?
I know that Facebook and other large systems do something like this but with C++, what you guys think?
A strategy similar to JSON (or json itself)
break the objects down to strings and map it to a C# object.
If you go with JSON it self you can get away with using some of the C# helpers already provided for translating Json.
Hope that helps.