Amadeus API - issue with the 'Flight Inspiration Search' API with 'origin' on LIVE mode - amadeus

I am attempting to ping: https://api.amadeus.com/v1/shopping/flight-destinations with origin 'MAN' on LIVE mode but receiving the following error:
{"errors":[{"status":500,"code":141,"title":"SYSTEM ERROR HAS OCCURRED","detail":"DATA DOMAIN NOT FOUND FOR REQUEST"}]}
I understand on TEST mode the origin airports are limited as per documentation on GutHub (https://github.com/amadeus4dev/data-collection/blob/master/data/flightsearch.md), but shouldn't this work on LIVE mode?
Here are the params I am passing:
$data = array(
'origin' => 'MAN',
'departureDate' => '2020-10-01,2020-10-31',
'oneWay' => "false",
'nonStop' => "false",
'maxPrice' => "300",
'viewBy' => 'COUNTRY'
);
When I change origin to 'LON' or 'LAX', it shows no errors and returns data. Do you know what is wrong? Many thanks in advance!

Related

Amadeus API - issue with the 'Flight Inspiration Search' API in test mode

I am attempting to get the 'Flight Inspiration Search' API working (https://developers.amadeus.com/self-service/category/air/api-doc/flight-inspiration-search/api-reference) and I am receiving the following error:
{
"errors":[{
"status":500,
"code":141,
"title":"SYSTEM ERROR HAS OCCURRED",
"detail":"Featured Results option is mandatory"
}]
}
I am using the API in test mode and I am passing the required params (also using the data specified on Github: https://github.com/amadeus4dev/data-collection/blob/master/data/flightsearch.md)
Just to confirm, here is what I am passing:
$data = array(
'origin' => 'LON',
'departureDate' => '2020-10-01',
'oneWay' => "false",
'duration' => "3",
'nonStop' => "false",
'maxPrice' => "300",
'viewBy' => 'COUNTRY'
);
Please note: I had to put the boolean values in quote marks as it was showing an error when passing as a boolean value.
Where am I going wrong? Many thanks in advance.
EDIT: This is the API endpoint I am using
https://test.api.amadeus.com/v1/shopping/flight-destinations

eBay API in Perl - can't use SetShipmentTrackingInfoRequest to update tracking information

I'm trying to figure out why I can't seem to update a tracking number using the eBay API. Here is the page I'm referencing:
http://developer.ebay.com/DevZone/merchant-data/CallRef/SetShipmentTrackingInfo.html
Based on that, I've got the following code in Perl:
use Net::eBay;
my $ebay = new Net::eBay( {
SiteLevel => 'prod',
DeveloperKey => 'x',
ApplicationKey => 'xxxx',
CertificateKey => 'xxx',
Token => 'xxxx',
} );
$ebay->setDefaults( { API => 2, compatibility => 900 } );
my $result = $ebay->submitRequest( "SetShipmentTrackingInfoRequest",
{
DetailLevel => "ReturnAll",
ErrorLevel => "1",
SiteId => "1",
OrderID => 1234546, # not the real order ID I'm using :)
ShipmentTrackingDetails => {
ShipmentTrackingNumber => "12345",
ShippingCarrierUsed => "Hermes"
}
});
print $IN->header;
use Data::Dumper;
print Dumper($result);
When running it, I get an error in $result:
$VAR1 = {
'Errors' => {
'ErrorClassification' => 'RequestError',
'SeverityCode' => 'Error',
'ShortMessage' => 'Unsupported API call.',
'ErrorCode' => '2',
'LongMessage' => 'The API call "SetShipmentTrackingInfoRequest" is invalid or not supported in this release.'
},
'xmlns' => 'urn:ebay:apis:eBLBaseComponents',
'Timestamp' => '2016-10-21 07:03:04',
'Build' => '18007281',
'Version' => '900',
'Ack' => 'Failure'
};
I'm a bit confused, as it looks like SetShipmentTrackingInfoRequest is the API call I need to be making? I've not really done much with the eBay API, so it's possible I'm missing something stupid.
UPDATE: As per feedback below, I'm now using the CompleteSale API call:
http://developer.ebay.com/Devzone/XML/docs/Reference/eBay/CompleteSale.html
my $result = $ebay->submitRequest( "CompleteSale ",
{
DetailLevel => "ReturnAll",
ErrorLevel => "1",
SiteId => "1",
OrderID => 1933420817015,
Shipment => {
ShipmentTrackingDetails => {
ShipmentTrackingNumber => "77293124902615",
ShippingCarrierUsed => "Hermes"
}
}
});
When I run it, I now get the error:
'LongMessage' => 'XML Error Text: "; nested exception is:
org.xml.sax.SAXParseException: Attribute name "Request" associated with an element type "CompleteSale" must be followed by the
\' = \' character.".',
Enabling debugging, the XML being sent is:
<?xml version='1.0' encoding='utf-8'?>
<CompleteSale Request xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>xxxx</eBayAuthToken>
</RequesterCredentials>
<DetailLevel>ReturnAll</DetailLevel>
<ErrorLevel>1</ErrorLevel>
<OrderID>xxxxx</OrderID>
<Shipment>
<ShipmentTrackingDetails>
<ShipmentTrackingNumber>xxxx</ShipmentTrackingNumber>
<ShippingCarrierUsed>Hermes</ShippingCarrierUsed>
</ShipmentTrackingDetails>
</Shipment>
<SiteId>1</SiteId>
</CompleteSale Request>
From looking at the eBay API doc link you posted doesn't the second 'Note' entirely explain why it doesn't work as a single API call?
Note: SetShipmentTrackingInfo cannot be issued on its own like an ordinary API call, using an endpoint
It then goes on to say:
In the Trading API, the CompleteSale call provides similar functionality that you can invoke directly
So perhaps looking there should be the next step

What's wrong with this Oauth process for LinkedIn + email?

I'm using the oneAuth bundle in laravel, based on NinjAuth from Fuel by Phil Sturgeon, I believe, and trying to get the user's email address.
I've added the proper scope to my request, and the LinkedIn auth screen successfully asks for the users permission for basic profile AND email address.. so far, so good..
A possible issue is: what is the proper name of the email field?
I've found references to email-address, emailAddress, 'emailaddress`...
The docs indicate email-address, but its not working for me :)
I'm using the URL: https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url,email-address)?format=json
This is the problematic snippet from /bundles/oneauth/libraries/oauth/provider/linkedin.php
// Create a response from the request
return array(
'uid' => array_get($user, 'id'),
// 'email' => array_get($user, 'email-address)',
// 'email' => array_get($user, 'emailAddress)',
'name' => array_get($user, 'firstName').' '.array_get($user, 'lastName'),
'image' => array_get($user, 'pictureUrl'),
'nickname' => $nickname,
'description' => array_get($user, 'headline'),
'location' => array_get($user, 'location.name'),
'urls' => array(
'linkedin' => $linked_url,
),
);
If I uncomment the email field, the request fails somehow (URL still shows mysite.com/connect/callback but the favicon shows linkedin and i get ablank page in chrome: "Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.")
If the email line in the code above IS commented out, I successfully receive all the other details and a new record is added to my users table and the table oneauth_clients, but email is naturally blank..
I must be missing something simple!
Update
The request URL works with email-address, but returns a json object containing emailAddress!!
The script still dies if the return array code above includes emailAddress...
Here is someone's success story:
"I made these two changes to the library and the demo.php respectively:
const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress';
$response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url,email-address)');
The issue was that the Request Token Call is:
https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url,email-address)?format=json
but the json response is:
array(8) {
["emailAddress"]=>
string(18) "email#email.com"
["firstName"]=>
string(3) "Tim"
...
Note that in the first case email is named email-address, in the second emailAddress.
The secondary problem was a shortcoming of my code - now working perfectly!

SSL for a website in Kohana

I have a website in Kohana 3.0.7 and I have purchased SSL certificate. I have marked the success page to which pay pal transaction details are returned with https. After the database is updated, I added following code -
$this->request->redirect('business/fnc_manage');
But this page is loaded with https and not loaded properly on Google Chrome.
If I try as following, it gives me 500 error -
header("Location:"+url::base()+"business/fnc_manage");
exit();
How can I get rid of this ? Does this mean that I'll have to ensure that all the resources loaded should be served over https ?
If yes, then I might have to change all the paths. How can I do it for HTML helpers ?
I have not tried it but I'd say changing the base_url in your bootstrap.php could help:
Kohana::init(array(
'base_url' => 'https://yoururlhere.com',
'index_file' => FALSE,
'charset' => 'utf-8',
'cache_dir' => APPPATH . 'cache',
'errors' => TRUE,
'profile' => Kohana::$environment !== Kohana::PRODUCTION,
'caching' => Kohana::$environment === Kohana::PRODUCTION,
));

Firebase GET data via REST API PHP CURL

Trying to do a simple read via PHP cURL. I can read my data successfully if my security rules let everyone in e.g.
{
"rules": {
".read": true,
".write": true
}
}
However if I restrict read/write to a specific username e.g.
{
"rules": {
".read": "auth.username == 'admin'",
".write": "auth.username == 'admin'"
}
}
I get permission denied.
The code is as follows...
require('JWT.php');
$secret = 'MY_FIREBASE_SECRET';
$data = array('username' => 'admin');
$token = JWT::encode($data, $secret);
$url = "https://MY_FIREBASE.firebaseio.com/messages.json?auth=$token";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url
));
$response = curl_exec($curl);
Its worth noting, if I just use my FB secret instead of a token in the URL I am able to successfully read the data (auth=$secret). I have also successfully tested reading the data in the Forge simulator using "custom auth" e.g. {'username': 'admin'}
I'm using the PHP JWT library: https://github.com/luciferous/jwt/blob/master/JWT.php
Not sure if I'm getting permission denied because my cURL call is not correct or I'm not constructing the token properly. I have tried using POST and GET via cURL but I'm getting the same result.
Any suggestions would be much appreciated...
Thanks for the super quick response Andrew. I tried your suggestion. Unfortunately, I'm still getting 'permission denied'. Here is my updated code...
require('JWT.php');
$secret = 'my-secret';
$user = array( 'v' => 0, 'iat' => time(), 'd' => array('username' => 'admin', 'type' => 'admin', 'fullname' => 'Administrator'));
$token = JWT::encode($user, $secret);
$curl = curl_init();
$url = "https://myfirebase.firebaseio.com/messages.json?auth=$token";
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url
));
$response = curl_exec($curl);
curl_close($curl);
I did get this working by changing the .read rule for our data to
"auth != null" - but that doesn't seem to quite as secure...
For reference our data structure is simply
+ myfirebase
+ messages
- 000001 = "this is the 1st test message"
- 000002 = "this is the 2nd test message"
BTW: Our application will only have 1 user reading/writing data. If I can not get the token to work... Is there a better way to authenticate calls via the REST API without resorting to passing our secret key in the URL? e.g. &auth='my-secret'
The Firebase JWT has some structure to it that is missing here. There's a detailed explanation of what should be in these auth tokens here:
https://www.firebase.com/docs/security/jwt-auth-token-format.html
Here is a snippet with the appropriate structure.
require_once('JWT.php');
$fbSecret = 'your-secret';
$user = array( 'v' => 0, 'iat' => <timestamp>,
'd' => array('username' => 'jimbob', 'type' => 'admin',\
'fullname' => 'Jim Bob')
);
$token = JWT::encode($user, $fbSecret);
Note that the "d" field contains the actual payload. "v", and "iat" are also required. "iat" should be the number of seconds since the epoch (it's the number that (new Date()).getTime() returns in Javascript).