Create and publish products with ebay API's - php

i need create and publish products in ebay with php , i find this sdk, but this not work for me, some have an code or example for this?
https://github.com/davidtsadler/ebay-sdk-php
in this sdk i get this error
Cannot read credentials from /.ebay_sdk/credentials in C:\wamp64\www\ebay\vendor\dts\ebay-sdk-php\src\Credentials\CredentialsProvider.php on line 132
but i changue the credentials in CredentialsProvider.php

I am using the same SDK (and it's amazing how awesome it is). The guy who created this SDK also provides some examples. You can find them all here. In the Trading folder, you will find 6 (I think) different examples of how to list an item using this SDK.
If you still have problems with the credentials, you could add the credentials manually (but I don't recommend it). Instead of using
$service = new Services\TradingService([
'credentials' => $config['sandbox']['credentials'],
'sandbox' => true,
'siteId' => $siteId
]);
you could use
$service = new Services\TradingService([
'credentials' => [
'devId' => 'YOUR_DEV_ID',
'appId' => 'YOUR_APP_ID',
'certId' => 'YOUR_CERT_ID',
],
'siteId' => EBAY_SITE_ID,
'sandbox' => true, // or false, up to you
'token' => 'YOUR_TOKEN'
]);

Related

bigcommerce rest api v3 php

I have to implement bigcommerce API integration with PHP
and I am trying to use the official library from https://github.com/bigcommerce/bigcommerce-api-php
and I am not even able to start step 1 here.
Issues:
Basic Auth method
Bigcommerce::configure(array(
'store_url' => 'https://store.mybigcommerce.com',
'username' => 'admin',
'api_key' => 'd81aada4xc34xx3e18f0xxxx7f36ca'
));
So the question here is how to get a username? bigcommerece user only created using email address so how to get username here?
OAuth method
In order to obtain the auth_token you would consume Bigcommerce::getAuthToken method
$object = new \stdClass();
$object->client_id = 'xxxxxx';
$object->client_secret = 'xxxxx;
$object->redirect_uri = 'https://app.com/redirect';
$object->code = $request->get('code');
$object->context = $request->get('context');
$object->scope = $request->get('scope');
$authTokenResponse = Bigcommerce::getAuthToken($object);
Bigcommerce::configure(array(
'client_id' => 'xxxxxxxx',
'auth_token' => $authTokenResponse->access_token,
'store_hash' => 'xxxxxxx'
));
here the question is what is the $request variable? also, redirect_uri is the bigcommerce store URL or my site URL?
Please can anyone help to get started with this?
It's because that library is a bit out of date with how api accounts are managed. For the basic auth you would use "legacy accounts". You can just use the OAuth method without the oAuth flow (assuming you're trying to connect to your own store, not create an app).
Just the following will work:
Bigcommerce::configure(array(
'client_id' => 'client-id',
'auth_token' => 'access-token',
'store_hash' => 'store-hash'
));
You should get these after creating a user in the dashboard (you can ignore the secret for this use case)

Credentials must be an instance of Aws\\Credentials\\CredentialsInterface error on PHP SDK with SQS

I am trying to delete a message from SQS in AWS using the php SDK. I have the following configuration.
$sqsClient = new SqsClient([
'version' => '2012-11-05',
'region' => 'us-east-1',
'credentials' => [
'key' => KEY,
'secret' => SECRET
]
]);
Then I am trying to delete like the following :
$sqsClient->deleteMessage([
'QueueUrl' => quque-url
'ReceiptHandle' => handle
]);
I am getting the following error on initialization :
Credentials must be an instance of Aws\\Credentials\\CredentialsInterface, an associative array that contains \"key\", \"secret\", and an optional \"token\" key-value pairs, a credentials provider function, or false."
The credentials I am using is correct. Before I was not passing the config and then also the same error was appearing. How this can be fixed ?
I found this code example and I think your code is correct.
How about create instance of Credentials?
You can use these code for initiating instance.
$credentials = new Aws\Credentials\Credentials(KEY, SECRET);
$sqsClient = new SqsClient([
'version' => '2012-11-05',
'region' => 'us-east-1',
'credentials' => $credentials
]);
Check this document.
And for security reason, I recommend that you'd better use credentials file or set environment variable.
I hope all is well.

The SenderID and SMSType is taking default one in AWS SNS sdk for PHP

I am using AWS SDK for PHP.
I am trying to send messages to numbers. Which is working for few numbers and will not work if DND is activated for South-east.
I tried both the Transactional and Promotional but which is not working for DND activated numbers. The senderID and smsType didn't change.
Which is taking the default one even though I mentioned the smsType and senderID.
Here is the link which I used to implement. I googled for samples. I didn't get any proper documentation for SNS using PHP.
I found an answer for my question. I am posting this code believing that it would help some one in need.
I was doing wrong in while passing the senderID and SMSType.
require './vendor/autoload.php';
use Aws\Sns\SnsClient;
$client = new SnsClient(['region' => 'ap-southeast-1', 'version' => 'latest',
'credentials' => ['key' => 'XXXXXXXXXXX', 'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXX']]);
$result = $client->publish(array('Message' => $message_mobile, 'PhoneNumber' => $mobile_no,
'MessageAttributes' => array('AWS.SNS.SMS.SMSType' => array('StringValue' => 'Transactional', 'DataType' => 'String'),
'AWS.SNS.SMS.SenderID' => array('StringValue' => 'LIMAHB', 'DataType' => 'String'))));

How to use LinkedIn People Search API

As there are several changes in LinkedIn People Search API as of now,please explain how to use this API for people search by company and etc...
I have read
https://developer-programs.linkedin.com/documents/people-search-api
and other document but not getting connection with search link and API key and all.As explained in document we can search some thing like this
https://api.linkedin.com/v1/people-search?keywords=Princess
but where we need to put API KEY and all. I am new to APIs so please if possible explain this.
I have also go through other blogs but they are old and not applicable.
If possible please also mention possibility and things we cann't do.
LinkedIn's People Search API has not been available to the open developer community since May, 2015.
You can apply to be a developer partner at: https://developer.linkedin.com/partner-programs/apply
If you are an official partner of LinkedIn and still have access to that API, you should follow up with your assigned Partner Engineering representative for further assistance, rather than public forums.
Use Postman to follow this tutorial:
https://developer.linkedin.com/docs/oauth2
On succes you can click to get the PHP code you need to create the request with OATH2. I have no developer account on LinkedIn so that part you have to do yourself.
The example GET request would look like this in PHP:
Step 2
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://www.linkedin.com/uas/oauth2/authorization');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
'response_type' => 'code',
'client_id' => '123456789',
'redirect_uri' => 'https://www.example.com/auth/linkedin',
'state' => '987654321',
'scope' => 'r_basicprofile'
)));
$request->setHeaders(array(
'cache-control' => 'no-cache'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Step 3
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://www.linkedin.com/uas/oauth2/accessToken');
$request->setRequestMethod('POST');
$request->setQuery(new http\QueryString(array(
'grant_type' => 'authorization_code',
'code' => '987654321',
'redirect_uri' => 'https://www.myapp.com/auth/linkedin',
'client_id' => '123456789',
'client_secret' => 'shhdonottell'
)));
$request->setHeaders(array(
'postman-token' => 'bee6f5d7-a0e6-4a76-6ef8-930c95af53a6',
'cache-control' => 'no-cache',
'content-type' => 'application/x-www-form-urlencoded',
'host' => 'www.linkedin.com'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

Amazon SNS to push topic using PHP

I'm trying to understand amazon php sdk for AWS but I really can't use it.
I find some basic classes to create, display and push topic but I doesn't work either.
I just want to find a way (the simplest way) to push a topic from my website.
First and foremost, to get acquainted with Amazon Simple Notification Service (SNS), I recommend to perform all required step manually once via the AWS Management Console as explained in the Getting Started Guide, i.e. Create a Topic, Subscribe to this Topic and Publish a message to it.
Afterwards it should be fairly straight forward to facilitate the sample fragments provided in the documentation of the AWS SDK for PHP running, see e.g. method publish() within class AmazonSNS:
$sns = new AmazonSNS();
// Get topic attributes
$response = $sns->publish(
'arn:aws:sns:us-east-1:9876543210:example-topic',
'This is my very first message to the world!',
array(
'Subject' => 'Hello world!'
)
);
// Success?
var_dump($response->isOK());
For a more complete example you might want to check out the the example provided in Sending Messages Using SNS [...].
If none of this works out, you'll have to provide more details regarding the specific problems you are encountering, as requested by tster already.
Good luck!
As told to you by #SteffenOpel, you should once try to perform all required steps manually once via the AWS Management Console.
Then you may use the AWS SDK for PHP(v3) as below to create the SNS client(or infact any service's client, surely with some changes) and then to create a SNS Topic.
<?php
//assuming that use have downloaded the zip file for php sdk
require 'C:/wamp/www/aws sdk/aws-autoloader.php'; //Change the path according to you
use Aws\Sns\SnsClient;
try{
/*-------------METHOD 1----------------*/
// Create a new Amazon SNS client using AWS v3
//$sns = new Aws\Sns\SnsClient([
$sns = new SnsClient([
'region' => 'us-west-2', //Change according to you
'version' => '2010-03-31', //Change according to you
'credentials' => [
'key' => '<Your root AWS Key',
'secret' => '<Your root AWS Secret>',
],
'scheme' => 'http', //disables SSL certification, there was an error on enabling it
]);
$result = $sns -> createTopic([
'Name' => '<Your Topic>',
]);
/*-------------METHOD 2----------------*/
/*
// Create a new Amazon SNS client using AWS v2
$sns = SnsClient::factory(array(
'region' => 'us-west-2',
'version' => '2010-03-31',
'credentials' => [
'key' => '<Your root AWS Key',
'secret' => '<Your root AWS Secret>',
],
'scheme' => 'http',
));
$result = $sns -> createTopic([
'Name' => '<Your Topic>',
]);
*/
/*-------------METHOD 3----------------*/
/*
// Create a new Amazon SNS client using AWS SDK class
// Use the us-west-2 region and latest version of each client.
$sharedConfig = [
'region' => 'us-west-2',
'version' => '2010-03-31',
'credentials' => [
'key' => '<Your root AWS Key',
'secret' => '<Your root AWS Secret>',
],
//'ssl.certificate_authority' => '/path/to/updated/cacert.pem',
'scheme' => 'http',
];
// Create an SDK class used to share configuration across clients.
$sdk = new Aws\Sdk($sharedConfig);
$sns = $sdk -> createSns();
$result = $sns -> createTopic([
'Name' => '<Your Topic>',
]);
*/
if ($result)
echo "Yes";
else
echo "No";
}
catch(Exception $e){
echo 'Caught Exception: ', $e->getMessage(), "\n";
}
?>
NOTE: This code illustrates creating the client for SNS in three different methods.
You may uncomment and use one according to your need.
Method 1 (version 3) is the best if you're creating a single client, else use Method 3. Method 2 is soon gonna depreciate (as its version 2)
I success to do it by using this classes->
Amazon-SNS-client-for-PHP
Very good, easy to use and working just great.
According to the AWS official docs here, we will have to create a SnsClient and call it's publish method. You can get topic's ARN from AWS console.
$SnSclient = new SnsClient([
'profile' => 'default',
'region' => 'us-east-1',
'version' => '2010-03-31'
]);
$message = 'This message is sent from a Amazon SNS code sample.';
$topic = 'arn:aws:sns:us-east-1:111122223333:MyTopic';
try {
$result = $SnSclient->publish([
'Message' => $message,
'TopicArn' => $topic,
]);
var_dump($result);
} catch (AwsException $e) {
// output error message if fails
error_log($e->getMessage());
}

Categories