Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm pretty basic at Perl, and I need to make a project for my university.
I want to download data from certain link, it is JSON data, so I know I have to use JSON::Parse module from CPAN.
But how to download content of link to my Perl variable? Should I use LWP get()?
Aren't you supposed to be learning Perl if it's a university project?
Anyway, your program will look something like this. It uses the LWP::Simple module to fetch the JSON data, and then JSON::Parse to process it into a Perl data structure
I've used printed the author value from each item of the array, as requested in your comment
use strict;
use warnings 'all';
use LWP::Simple 'get';
use JSON::Parse 'parse_json';
use constant URL => 'http://a.wykop.pl/observatory/entries/appkey,dJ4w7fXYpL';
my $json = get URL or die "Unable to get JSON data";
my $data = parse_json($json);
print "Authors:\n";
print " $_->{author}\n" for #$data;
output
Authors:
Snurq
AferaZaAfera
Devest
igorsped
Matt23
labla
poprawnie-niepoprawny
Parkero
Speed666
Xune
Gasior9
mikolajeq
Aztek2201
blogerbezbloga
Pan_wons
PanKaczucha
NieznanyAleAmbitny
dzika_kaczka_bez_dzioba
ilili
Bager
bmbcz01
hydrocyfolumpus
acarter
Doctor_Manhattan
strumienzgor
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
my Services.ts
deteleComentario(id: number): Observable<any>{
return this.http.delete(this.myAppUrl + this.myApiUrl + id);
}
my list-Comment-Component.ts
eliminarComentario(id: any ){
this.comentarioService.deteleComentario(id).subscribe(data => {
this.getComentarios();
}, error => {
console.log(error);
}
);
}
And my Api, NetCore with Mysql it`s work fine in GET, POST, GET{ID}, PUT{ID}, DELETE{ID}
any suggestion what could be the problem
The 415 Unsupported Media Type is a client-side error that indicates the request entity has a media type that the server or resource does not support. The response code may still be returned if the contents of the request body were not supported by the server. For example, a server might support specific JSON bodies, but the payload contents didn't validate, perhaps because it was missing a required property.
For example, the client uploads an image that was not in one of the formats (e.g., JPEG, PNG), or a video that is not in an accepted format (e.g., MPEG). The best way to fix it is to remove the image or video and upload a file in one of those formats.
Please see documentation for more information.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I'm writing a Google apps script to update an event. I tried using the path API like below:
event_ins.setVisibility('private');
Logger.log('Making event %s %s private %s',calendarId, event_ins.summary, event_ins);
Calendar.Events.patch(event_ins,calendarId, eventID_ins);
I get the following error message:
11:28:30 AM Error HttpResponseException: Response Code: 404. Message: Not Found.
I tried using the update method instead
Calendar.Events.update(event_ins,calendarId,eventID_ins);
I'm still getting the same error.
The examples in Google's API documentation does not use Google script. I tried searching example code and I found similar usage. For instance this is from here :
event = Calendar.Events.patch(event, calendarId, eventId, {
sendNotifications: true
});
I would appreciate any help to get this working.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
What is the best way to import a 15,000 document json file of a format (but with a +30 foo fields)
[{"foo1":"foo1data1", "foo2":"foo2data1"}, {"foo1":"foo1data2", "foo2":"foo2data2"}...
{"foo1":"foo1dataN", "foo2":"foo2dataN"}])
to a Meteor collection?
I tried with mongoimport but that created ObjectID's instead of _id's and I could not make it work without autopublish, although other collections, created with Meteor, work just fine on client side.
Supposing the file is located on the server under pathToFile you can do something like this:
var fs = Npm.require("fs");
var Fiber = Npm.require("fibers");
fs.readFile(pathToFile, 'utf8', function (err, data) {
// handle error if there is some
data = JSON.parse(data);
Fiber(function () {
_.each(data, function (document) {
SomeMeteorCollection.insert(document);
});
}).run();
});
Please note that Fiber wrapper is required if you want call any meteor specific routines, for example collections API, within some nodejs asynchronous code.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there any JavaScript API available for tracking Fedex and UPS packages?
I googled for something like this but couldn't find anything. Then I decided to do it server side in ROR.
Here it is how to get UPS and Fedex xml request and response from their test servers.
For Fedex:
track_no = '111111111111' # This is a test tracking number
# This XML Request body for fedex
xml_req =
"<TrackRequest xmlns='http://fedex.com/ws/track/v3'><WebAuthenticationDetail><UserCredential><Key>YOUR_ACC_KEY</Key>
<Password>YOUR_ACC_PASSWORD</Password></UserCredential></WebAuthenticationDetail><ClientDetail>
<AccountNumber>YOUR_ACC_NUMBER</AccountNumber><MeterNumber>YOUR_ACC_METER_NUMBER</MeterNumber></ClientDetail>
<TransactionDetail><CustomerTransactionId>ActiveShipping</CustomerTransactionId></TransactionDetail>
<Version><ServiceId>trck</ServiceId><Major>3</Major><Intermediate>0</Intermediate><Minor>0</Minor></Version>
<PackageIdentifier><Value>#{track_no}</Value><Type>TRACKING_NUMBER_OR_DOORTAG</Type></PackageIdentifier>
<IncludeDetailedScans>1</IncludeDetailedScans></TrackRequest>"
path = "https://gatewaybeta.fedex.com:443/xml"
#this url connects to the test server of fedex
# for live server url is:"https://gateway.fedex.com:443/xml"
url = URI.parse(path)
http = Net::HTTP.new(url.host,url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.post(url.path, xml_req)
response_body = response.body
res = response_body.gsub(/<(\/)?.*?\:(.*?)>/, '<\1\2>')
hash = Hash.from_xml(res.to_s)
And that's it! You will get response in hash variable, I converted xml response in to Hash because we can easily use Hash object at our view to display response data.
For UPS:
track_no = '1Z12345E1512345676' # This is a test tracking number
# This XML Request body for UPS
xml_req =
'<?xml version="1.0"?><AccessRequest xml:lang="en-US"><AccessLicenseNumber>YOUR_ACC_LICENCE_NUMBER</AccessLicenseNumber>
<UserId>YOUR_ACC_USER_ID</UserId><Password>YOUR_ACC_PASSWORD</Password></AccessRequest>
<?xml version="1.0"?><TrackRequest xml:lang="en-US"><Request><TransactionReference>
<CustomerContext>QAST Track</CustomerContext><XpciVersion>1.0</XpciVersion></TransactionReference>
<RequestAction>Track</RequestAction><RequestOption>activity</RequestOption></Request>
<TrackingNumber>#{track_no}</TrackingNumber></TrackRequest>'
path = "https://www.ups.com/ups.app/xml/Track"
url = URI.parse(path)
http = Net::HTTP.new(url.host,url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.post(url.path, xml_req)
response_body = response.body
hash = Hash.from_xml(response_body.to_s)
This hash variable contains the response of UPS Tracking Request in Hash format.
another easy way to do it: Just create a hyperlink with the following href
UPS:
http://wwwapps.ups.com/WebTracking/track?loc=en_US&track.x=Track&trackNums=put_tracking_number_here
FEDEX:
http://fedex.com/Tracking?action=track&language=english&cntry_code=us&tracknumbers=put_tracking_number_here
(not as elegant, but quick, easy and gets the job done!)
Or you can use the active_shipping gem for a nicer and cleaner way to track your packages for Fedex and UPS
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
How do I install json in xampp server?
Json is a format; you don't install it, you implement it.
If you want to use the json format in your php website, there's an extension that provides functions you can use to encode data in a json format.
To install or use the extension, please see the installation page; depending on your version of php you may have the json extension already bundled with xampp. If you've got the latest version of xampp (windows install), it's ok to use the methods directly
Xampp is "shipped" with Apache, MySQL, PHP, Perl and support for JSON in PHP and Perl!
Json PHP
Json Perl: JSON::to_json(hash);
Simple PHP example from php.net
<?php
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);
?>
EDIT: Second example showing how to json_encode() a mysql query result:
<?php
$sth = mysql_query("SELECT ...");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
?>
EDIT 2: You are then able to convert JSON to XML using one of the described methods from this stackoverflow question.
Edit3: If you want to save the xml file to disc use
$myFile = "file.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
$data = x; // replace x with the xml from your ajax result !!!!!
fwrite($fh, $data);
fclose($fh);