I22r-Translate-Microsoft
    
    
  
  
  
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
requires 'LWP::UserAgent' => 0;
requires 'XML::XPath' => 0;
requires 'URL::Encode' => 0;
test_requires 'Test::More' => 0;
auto_install;
WriteAll;
print STDERR qq[
*******************************************************************
Using the Microsoft translation backend requires credentials for
Microsoft data services. If you wish to test the Micrsoft backend, 
you will need to edit the file
       t/Constants.pm
and specify your credentials. See the perldoc for 
I22r::Translate::Microsoft for information about obtaining a
set of credentials for yourself, or
       http://search.cpan.org/perldoc?I22r-Translate-Microsoft#CREDENTIALS
*******************************************************************
];
Translates content from one supported language to another, using
the Microsoft Translator webservice with the  I22r::Translate
framework. See the  I22r::Translate  for more information.
To use the Microsoft Translator API, you must set up an account
at the "Windows Azure Marketplace", choose a translator API
data plan, and "register an application" to get a "client ID"
and a "client secret" that you must provide to this module.
See the instructions below or the  I22r::Translate::Microsoft
documentation on how to get these credentials.
INSTALLATION
To install this module, run the following commands:
	perl Makefile.PL
	make
	make test
	make install
TESTING WITH MICROSOFT DATA SERVICES CREDENTIALS
If you have registered for data services from Microsoft
and want to use your credentials with the unit tests in
this distribution, edit the bottom of the file
t/Constants.pm  before you run "make test". See the
documentation for the  I22r::Translate::Microsoft
package for some (possibly outdated) information about
how to obtain those credentials.
If you do not specify your credentials (a "client id"
and a "secret"), then the unit tests that interact with
Microsoft's data services will be skipped.
CONFIGURATION
This Microsoft backend is used in conjunction with the
I22r::Translate  framework. You configure the framework
with a call to  I22r::Translate->config  , passing a 
key-value pair with the key "I22r::Translate::Microsoft".
A minimal configuration would look like:
The  CLIENT_ID  and  SECRET  parameters are required. See
the  I22r::Translate::Microsoft  and  I22r::Translate
documentation about other possible parameters.
GETTING CREDENTIALS FOR MICROSOFT TRANSLATOR API
You will need to obtain and provide a "client id" and
"client secret" to the  I22r::Translate  framework to
use the Microsoft backend. As of October 2012, here are
the instructions for getting these credentials:
1. If you don't have a  Windows Live ID , sign up
   for one at L<https://signup.live.com/signup.aspx?lic=1>    
2. Visit  https://datamarket.azure.com/dataset/bing/microsofttranslator .
   Register for a "Windows Azure Marketplace" account.
3. Choose a Microsoft Translator data plan. One of the
   available plans is a free option for 2,000,000 characters/month.
Then you would configure the Microsoft backend with
    I22r::Translate->config(
        'I22r::Translate::Microsoft' => {
            ENABLED => 1,
            CLIENT_ID => "angus",
            SECRET => "ykiDjfQ9lztW/oFUC4t2ciPWH2nJS88FqXcQbs/Z9Y=7"
        } );
(these are not real credentials).
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the
perldoc command.
    perldoc I22r::Translate::Microsoft
You can also look for information at:
lib/I22r/Translate/Microsoft.pm view on Meta::CPAN
	return;
    }
    if (!$token->{secret} || $token->{secret} ne $secret) {
	$token->{secret} = $secret;
	$token->{secretx} = url_encode( $secret );
    }
    $token->{client_idx} = url_encode( $client_id );
    my $content = join( '&', 
			'grant_type=client_credentials',
			'client_id=' . $token->{client_idx},
			'client_secret=' . $token->{secretx},
			'scope=http://api.microsofttranslator.com/' );
    my $headers = HTTP::Headers->new(
	'Content-Type', 'application/x-www-form-urlencoded');
    $token->{ua} //= LWP::UserAgent->new;
    my $request = HTTP::Request->new(
	POST => TOKENAUTH_URL,
	$headers, $content );
lib/I22r/Translate/Microsoft.pm view on Meta::CPAN
sending text to the Microsoft Translate webservice.
=back
=head1 CREDENTIALS
This package interacts with the Microsoft Translator API,
which requires some you/us to provide a "client id" and
"client secret" to access Microsoft's data services.
As of October 2012, here are the steps you need to take
to get those credentials. (If these steps don't work anymore,
and you do figure out what steps you need to do, L<let me 
know|mailto:mob@cpan.org> or L<file a bug report|"SUPPORT">
and I'll update this document.
=over 4
=item 1. 
If you don't have a  Windows Live ID , sign up
for one at L<https://signup.live.com/signup.aspx?lic=1>    
lib/I22r/Translate/Microsoft.pm view on Meta::CPAN
Then you would configure the Microsoft backend with
    I22r::Translate->config(
        'I22r::Translate::Microsoft' => {
            ENABLED => 1,
            CLIENT_ID => "angus",
            SECRET => "ykiDjfQ9lztW/oFUC4t2ciPWH2nJS88FqXcQbs/Z9Y=7"
        } );
(these are not real credentials).
=back
=head1 AUTHOR
Marty O'Brien, C<< <mob at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to 
t/Constants.pm view on Meta::CPAN
      } );
}
# t/Constants.pmx is a separate file, not included in
# the released distribution, that contains my personal
# API keys for testing and development.
if (-f "t/Constants.pmx" && !$ENV{RELEASE}) {
    # t/Constants.pmx is a file, not included in this distribution,
    # that resides on the author's system and includes his credentials
    # for Microsoft data services.
    require "t/Constants.pmx";
} else {
    $t::Constants::BING_CLIENT_ID = "not used yet";
    $t::Constants::BING_SECRET = "not_used_until_we_add_MS_backend";
    $t::Constants::CONFIGURED = 0;
}
1;
( run in 1.278 second using v1.01-cache-2.11-cpan-c333fce770f )