I have downloaded a PHP SDK for the UPS API. I have the following code and have no idea what an end point URL is. The documentation does not provide any information on what this is.
//Configuration
$access = "0C81234564C2567";
$userid = "leannetest";
$passwd = "456hththd8hf";
$accessSchemaFile = "schemas/AccessRequest.xsd";
$requestSchemaFile = "schemas/RateRequest.xsd";
$responseSchemaFile = "schemas/RateResponse.xsd";
$endpointurl = 'add URL here';
$outputFileName = "XOLTResult.xml";
Can anyone help?
Endpoint url explaination in the UPS document. it consists of four parts which are explained below.
For example if we are going to use "Rate" service than our urls should be as below.
Testing and integration URL : https://wwwcie.ups.com/ups.app/xml/Rate
Production URL : https://onlinetools.ups.com/ups.app/xml/Rate
As per the documentation if we devide the url in four parts all of them are as listed below.
Protocol : https
Name of server : wwwcie.ups.com (testing) OR onlinetools.ups.com (production)
Path of service : ups.app/xml/Rate
name of the service : Rate OR Ship OR QVEvents
I just replied to explain UPS endpoint url in detail so it might help
An API endpoint "defines the address or connection point to a Web service. It is typically represented by a simple HTTP URL string". So basically, the endpoint URL is the URL of the web service that are you attempting to interact with.
SOURCE:
http://en.wikipedia.org/wiki/Web_Services_Description_Language#Objects_in_WSDL_1.1_.2F_WSDL_2.0
EDIT: It appears from the documentation that the Rate webservices endpoint URL is https://wwwcie.ups.com/webservices/Rate.
SOURCE:
UPS. (January 2, 2002). Rating Package Web Services Developers Guide. Section 1.9.3 Server Availability Check. Accessed in Rating API found on this page: https://www.ups.com/upsdeveloperkit/downloadresource?loc=en_US
The shipping endpoint url is:
https://wwwcie.ups.com/webservices/Ship
In case anyone needs it, since it's not documented in their developers kit.
Indeed the documentation is poor but with a little google trick I got the list of all the endpoint URLs
Type in google search:
site:https://onlinetools.ups.com/ups.app/xml/
In this way, it will show you all the endpoints.
Note: Do not use the sandbox URLs because they don't work at all :(
Anyway, here is the list:
https://onlinetools.ups.com/ups.app/xml/TimeInTransit
https://onlinetools.ups.com/ups.app/xml/License
https://onlinetools.ups.com/ups.app/xml/QVEvents
https://onlinetools.ups.com/ups.app/xml/Register
https://onlinetools.ups.com/ups.app/xml/AV
https://onlinetools.ups.com/ups.app/xml/ShipAccept
https://onlinetools.ups.com/ups.app/xml/Void
https://onlinetools.ups.com/ups.app/xml/XAV
https://onlinetools.ups.com/ups.app/xml/Track
https://onlinetools.ups.com/ups.app/xml/Rate
https://onlinetools.ups.com/ups.app/xml/ShipConfirm
https://onlinetools.ups.com/ups.app/xml/LabelRecovery
I hope this help
Related
In amazon selling partner api , canonical request and string to sign is coming as expected, code after that is below:
{
$kDate=hash_hmac('sha256',$date,'AWS4'.$secretKey,true); //only date. $kRegion=hash_hmac('sha256',$region,$kDate,true); $kService=hash_hmac('sha256',$service,$kRegion,true); $kSigning=hash_hmac('sha256','aws4_request',$kService,true); $signature=hash_hmac('sha256',$stringToSign,$kSigning);
}
Can anyone help me with what's wrong in it, Thanks in advance.
Output coming after running script
I am a novice for Azure SSO so I might have missed some obvious things here - please have that in mind ;-)
I need to integrate my application to Azure Active Directory. There is not much help to get in our organisation for that so I am left for myself to find the problem here :-/ My exact problem is that when I login then I get this error from Azure:
AADSTS50011: The reply URL specified in the request does not match the
reply URLs configured for the application: 'https://192.168.0.1/secure/'.
I have of course searched for how to solve this myself but I didn't find anything that could get me any closer.
I have this setup:
IIS
PHP
simpleSAMLphp
Azure AD
I have not setup nor access to the Azure part as this is setup by our IT guys but they have setup this:
Basic SAML Configuration
Identifier (Entity ID) : https://192.168.0.1/secure/
Reply URL (Assertion Consumer Service URL) : https://192.168.0.1/secure/
Sign on URL : Optional
Relay State : Optional
Logout URL : Optional
I have recived a federation XML file from Azure and have converted/populated that in to the simpleSAMLphp file \metadata\saml20-idp-remote.php
I have setup the \config\authsources.php file:
'entityID' => "https://192.168.0.1/secure/",
'idp' => "https://sts.windows.net/06dg12k9-1wl2-4mue-79gh-40ff1a8dnd4a/",
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
'simplesaml.nameidattribute' => 'eduPersonTargetedID',
Everything has been configured with this guide in mind, https://www.lewisroberts.com/2015/09/05/single-sign-on-to-azure-ad-using-simplesamlphp/
When I launch https://192.168.0.1/simpleSAMLphp/www/ and go to Authentication and Test configured authentication sources and I test with default-sp then I do get an Azure login screen. If I view the URL for that then it looks like this:
https://login.microsoftonline.com/0ad94219-6af5-474e-99d0-60f9188f3fce/saml2
?SAMLRequest=f[CUT]2Fy%2Fi%2Bjc%3D
&RelayState=https%3A%2F%2F192.168.0.1%2FsimpleSAMLphp%2Fwww%2Fmodule.php%2Fcore%2Fauthenticate.php%3Fas%3Ddefault-sp
I assume the RelayState is where the request comes from on my server. I have tried to setup the Entity ID and Reply URL in Azure to be https://192.168.0.1/simpleSAMLphp/www/module.php/core/authenticate.php?as=default-sp but with the same result.
So I have provided everything I know here but I am really blank on how to fix this problem? Do I need to configure a Reply URL in simpleSAMLphp so it is passed as an URL parameter?
Any help would really be appreciated.
### UPDATE 1 - another problem ###
After revising the logfile from simpleSAMLphp then it showed what was sent to Azure:
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_25e3fb2" Version="2.0" Destination="https://login.microsoftonline.com/088f3fce/saml2" AssertionConsumerServiceURL="https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/saml2-acs.php/default-sp" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST">
<saml:Issuer>https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/metadata.php/default-sp</saml:Issuer>
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" AllowCreate="true"/>
</samlp:AuthnRequest>
I then took the AssertionConsumerServiceURL from there and used that as Reply URL in Azure. Also I took the Entity ID from the simpleSAMLphp Federation page and now the simpleSAMLphp demo page works :-)
So my Azure setup now looks like this:
Basic SAML Configuration
Identifier (Entity ID) : https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/metadata.php/default-sp
Reply URL (Assertion Consumer Service URL) : https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/saml2-acs.php/default-sp
Sign on URL : Optional
Relay State : Optional
Logout URL : Optional
(note the difference in the URL)
However I sadly still have problems. When I have a PHP file in my web scope with this content:
<?PHP
require_once ("../../simpleSAMLphp/lib/_autoload.php");
$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
$attributes = $as->getAttributes();
echo '<pre>';
print_r($attributes);
echo '</pre>';
// Get a logout URL
$url = $as->getLogoutURL();
echo 'Logout';
?>
Then it ends up in an infinite loop redirecting between my server and Azure!? Viewing the log provide no major insight for me. It seems that I do receive data from Azure and that I am authenticated as I can see the user attributes in the debug log but ... if I am authenticated then why am I redirected back to Azure!?
### UPDATE 2 - solution ###
After a few more hours of looking in the simpleSAMLphp logfile and cleaning out the WARNINGS (they are actually important) then I found out that my infinite redirection was caused by a mismatch between the PHP sessions and simpleSAMLphp sessions.
My solution was to align the two and have the exact same settings all places. Make sure to check the php.ini session settings and the \config\config.php session settings and make them identical.
Also I found out that the PHP source code I have used is for an older version of simpleSAMLphp though I don't think it was a problem.
Instead of this old method:
$as = new SimpleSAML_Auth_Simple('default-sp');
Then it should be this new method:
$as = new \SimpleSAML\Auth\Simple('default-sp');
RelayState is just a parameter that is echoed back to your SP as-is. It can be used to store the page url the user tried to access before authentication, for example.
If you're using SAML2, the replyURL should be your AssertionConsumerService url in your SP metadata. Azure will send the SAML Response there. If that url differs from https://192.168.0.1/secure/ you will get that error. Even a missing trailing / will cause the error.
Alright so I am having some troubles understanding how to use the open weather API.
I have tried using it as
<?php
$request = file_get_contents('http://api.openweathermap.org/data/2.5/forecast/city?id=myidblablabla'); //example ID
$jsonPHP = json_decode($request);
echo $jsonPHP->city;
?>
But I get an error saying
Catchable fatal error: Object of class stdClass could not be converted
to string in
Now there is 1 more question that I have to ask, how do I get certains City Temperature, humidity etc? From the code I received I get only Moscow
To simplify it, you can also transform the json into array instead.
$jsonPHP = json_decode($request,true);
Now let's discuss it briefly. According to the documentation (http://openweathermap.org/current),
Note also that I've never used this API before. I'm just trying to help here.
If you hit api.openweathermap.org/data/2.5/weather?lat=35&lon=139
It responds as
{"coord":{"lon":139,"lat":35},
"sys":{"country":"JP","sunrise":1369769524,"sunset":1369821049},
"weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],
"main":{"temp":289.5,"humidity":89,"pressure":1013,"temp_min":287.04,"temp_max":292.04},
"wind":{"speed":7.31,"deg":187.002},
"rain":{"3h":0},
"clouds":{"all":92},
"dt":1369824698,
"id":1851632,
"name":"Shuzenji",
"cod":200}
Now assuming you want to take the weather and humidity , it just :
weather :
echo $jsonPHP["weather"][0]["id"];
humidity:
echo $jsonPHP["main"]["humidity"];
Note also that, If you hit http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139 and get the responds as
{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}
For the case, they've explained here :
http://openweathermap.org/faq#error401 which is :
Q: API calls return an error 401
A: Starting from 9 October 2015 our
API requires a valid APPID for access. Note that this does not mean
that our API is subscription-only now - please take a minute to
register a free account to receive a key.
We are sorry for inconvenience but this is a necessary measure that
will help us deliver our services to you faster and more reliably.
For FOSS developers: we welcome free and open source software and are
willing to help you. If you want to use OWM data in your free software
application please register an API key and file a ticket describing
your application and API key registered. OWM will review your request
lift access limits for your key if used in open source application.
In API 1.0, we can use users/profile_image/:screen_name
For example : http://api.twitter.com/1/users/profile_image/EA_FIFA_FRANCE
But, it doesn't work anymore in API 1.1.
Do you have a solution, please ?
You can also get the twitter profile image by calling this kind of url :
https://twitter.com/[screen_name]/profile_image?size=original
For instance : https://twitter.com/VancityReynolds/profile_image?size=original
Got the info from this post :
https://twittercommunity.com/t/how-to-get-user-image-original-size-with-api-1-1/10187/14
The user's profile image
Okay, so you want a user's profile image. You're going to need to take a look at the twitter REST API 1.1 docs. This is a list of all the different requests you can make to their API (don't worry, I'll get to how you actually do this later on).
There are multiple ways to get the user's profile image, but the most notable one is: users/show. According to the docs for this, the users/show method:
Returns a variety of information about the user specified by the required user_id or screen_name parameter. The author's most recent Tweet will be returned inline when possible.
Well, the user profile image must be in there somewhere, correct?
Let's have a look at a typical response to a request for this information, using the users/show url (we'll use my profile as an example).
I've cut off some from the bottom, because there is a lot of data to go through. Most importantly, you'll see what you require:
This is the profile_image_url key that you need to get access to.
So, how do you do all this? It's pretty simple, actually.
Authenticated Requests
As you rightly pointed out, as of June 11th 2013 you can't make unauthenticated requests, or any to the 1.0 API any more, because it has been retired. So OAuth is the way to make requests to the 1.1 API.
I wrote a stack overflow post with an aim to help all you guys make authenticated requests to the 1.1 API with little to no effort.
When you use it, you'll get back the response you see above. Follow the posts instructions, step-by-step, and you can get the library here (you only need to include one file in your project).
Basically, the previous post explains that you need to do the following:
Create a twitter developer account
Get yourself a set of unique keys from twitter (4 keys in total).
Set your application to have read/write access
Include TwitterApiExchange.php (the library)
Put your keys in a $settings array
Choose your URL and request method (Post/Get) from the docs (I put the link above!)
Make the request, that's it!
A practical example
I'm going to assume you followed the step-by-step instructions in the above post (containing pretty colour pictures). Here's the code you would use to get what you want.
// Require the library file, obviously
require_once('TwitterAPIExchange.php');
// Set up your settings with the keys you get from the dev site
$settings = array(
'oauth_access_token' => "YOUR_ACCESS_TOKEN",
'oauth_access_token_secret' => "YOUR_ACCESS_TOKEN_SECRET",
'consumer_key' => "YOUR_CONSUMER_KEY",
'consumer_secret' => "YOUR_CONSUMER_SECRET"
);
// Chooose the url you want from the docs, this is the users/show
$url = 'https://api.twitter.com/1.1/users/show.json';
// The request method, according to the docs, is GET, not POST
$requestMethod = 'GET';
// Set up your get string, we're using my screen name here
$getfield = '?screen_name=j7mbo';
// Create the object
$twitter = new TwitterAPIExchange($settings);
// Make the request and get the response into the $json variable
$json = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
// It's json, so decode it into an array
$result = json_decode($json);
// Access the profile_image_url element in the array
echo $result->profile_image_url;
That's pretty much it! Very simple. There's also users/lookup which effectively does the same thing, but you can:
Returns fully-hydrated user objects for up to 100 users per request, as specified by comma-separated values passed to the user_id and/or screen_name parameters.
If you ever need to get more than one user's details, use that, but as you only require one user's details, use users/show as above.
I hope that cleared things up a bit!
You say you want to use Twitter API 1.1 and yet you don't want to authenticate your requests.
Unauthenticated requests are not supported in API v1.1. So please adjust to the API change. See updates :
https://dev.twitter.com/blog/planning-for-api-v1-retirement
https://dev.twitter.com/docs/rate-limiting/1.1
You can get image from profile_image_url field of https://api.twitter.com/1.1/users/show.json request. Either a id or screen_name is required for this method. For example :
GET https://api.twitter.com/1.1/users/show.json?screen_name=rsarver
See details here https://dev.twitter.com/docs/api/1.1/get/users/show
I try the above methods to get the profile URL but it does not work for me. I think because Twitter changes API v1.1 to API v2.0.
I found a simple method to get a profile URL.
I use Twitter API v2 there User Lookup -> User by Username API part
Code Sample:
https://api.twitter.com/2/users/by/username/{user_name}?user.fields=profile_image_url
For Example:
https://api.twitter.com/2/users/by/username/TwitterDev?user.fields=profile_image_url
Of course, You should request with your Bearer Token then it properly work. For that, I recommend a platform it calls postman. It really helps for calling API.
Above example code return JSON like this:
{
"data": {
"name": "Twitter Dev",
"profile_image_url": "https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
"username": "TwitterDev",
"id": "2244994945"
}
}
Additional:
If You want the Profile Image to be a higher size. Then you can put size in place of normal in the URL. For More Details read this one
Like This:
https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_400x400.jpg
Give a vote to help more developers. 🍵
As the previous answers and comments point out:
Twitter API v1.0 is deprecated
Twitter API v1.1 requires OAuth
OP (#Steffi) doesn't want to authenticate
Pick any two; with all three it's a no-go. #Jimbo's answer is correct (and the proper way to do it), but excludes #3. Throwing out #1 means going back in time. But, we can throw out #2, and go directly to the source:
curl -s https://twitter.com/EA_FIFA_FRANCE |
sed -ne 's/^.*ProfileAvatar-image.*\(https:[^"]*\).*$/\1/p'
The sed command just says, find the line that contains "ProfileAvatar-image" and print the substring that looks like a quoted URL.
This is less stable than an authenticated API call, since Twitter may change their HTML at any time, but it's easier than dealing with OAuth, and no official rate limits!
The PHP translation should be straightforward.
try this
http://api.twitter.com/1/users/profile_image/{twitter_account}.xml?size=bigger
In API 1.1 the only way is to connect your application, retrieve the user by
https://dev.twitter.com/docs/api/1.1/get/users/show
and retrieve after his picture
profile_image_url
Hare is a very simple way to get Twitter Profile picture.
http://res.cloudinary.com/demo/image/twitter_name/w_300/{User_Name}.jpg
it's my Profile picutre:
Big: http://res.cloudinary.com/demo/image/twitter_name/w_300/avto_key.jpg
Small: http://res.cloudinary.com/demo/image/twitter_name/w_100/avto_key.jpg
you can regulate size by this part of URL - w_100, w_200, w_500 and etc.
I would like to create a SOAP Web service for the followıng wsld
http://www.webservicex.com/CurrencyConvertor.asmx?WSDL
Could you please explain how to do this?
The following code is not working... Please help me..
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("http://www.webservicex.com/CurrencyConvertor.asmx?wsdl");
$CURR = array("FromCurrency" => "USD","ToCurrency" => "INR");
$scramble = $client->ConversionRate($CURR);
$mirror = $client->ConversionRateResponse($scramble);
Thanks,
Praveen J
Let's start with your client URL:
http://www.webservicex.com/CurrencyConvertor.asmx?wsdl
This is wrong. The ?WDSL URL is NOT the URL you use for CALLING the web service, it is the URL you use to retrieve the WDSL that describes the web service. THis is used by automatic tools to generate a wrapper.
http://www.webservicex.com/CurrencyConvertor.asmx
is the "real" URL that you use to execute operations.
http://www.webservicex.com/CurrencyConvertor.asmx?op=ConversionRate
Has a more invormation on the conversion per se, including the exact parameters with naming you need for the Post and GET operations, including examples.