PHP Betfair Free Access API, how to build APIRequestHeader & call any method? - php

I am trying to write a simple PHP client to get some data from Betfair through the Free Access API http://bdp.betfair.com/?option=com_content&task=view&id=33&Itemid=62
I can login & get a session token, this way
$wsdl = 'https://api.betfair.com/global/v3/BFGlobalService.wsdl';
$soapClient = new SoapClient($wsdl);
try {
$ap_param = array(
'request' =>
array(
'username' => 'my_username',
'password' => 'my_password',
'productId' => '82',
'ipAddress' => '',
'locationId' => '',
'vendorSoftwareId' => '',
),
);
$response = $soapClient->__call("login", array($ap_param));
...
$response is an object containing the sessionToken param
But after several tries I am afraid I am sending the APIRequestHeader param (http://bdp.betfair.com/docs/) malformed, cause the response to any call (getAllEventTypes, for instance) is always returning the same: NO_SESSION
One try...
$ap_param = array(
'request' =>
array(
'header' => array(
'session_token' => $response->Result->header->sessionToken,
'clientStamp' => 0,
),
),
);
Another try...
$ap_param = array(
'request' =>
array(
'session_token' => $response->Result->header->sessionToken,
'clientStamp' => 0,
),
);
And lot of other tries... but
$response = $soapClient->__call("getAllEventTypes", array($ap_param));
$response is always the same
stdClass Object
(
[Result] => stdClass Object
(
[header] => stdClass Object
(
[errorCode] => NO_SESSION
[minorErrorCode] =>
[sessionToken] =>
[timestamp] => 2013-11-09T08:41:01.015Z
)
[eventTypeItems] =>
[minorErrorCode] =>
[errorCode] => API_ERROR
)
)
Someone here has faced the same problem?

Stupid typo error there...
session_token should be sessionToken
$ap_param = array(
'request' =>
array(
'header' => array(
'sessionToken' => $response->Result->header->sessionToken,
'clientStamp' => 0,
),
),
);

Related

Posting data using Guzzle

I am trying to post data using Guzzle 6,
The request which I am generating dynamically looks as below:
$postRequest = Array(
'headers' => array(
['x-api-key'] => 'srDxd39M2FQxxvfvxxcIohcLfKDcdcRUU'
)
'form_params' => array(
[0] => Array (
['name'] => 'function_key'
['contents'] => 'REGISTER'
)
[1] => Array (
['name'] => 'email'
['contents'] => 'tester#test.com'
)
[2] => Array (
['name'] => 'password'
['contents'] => 'test'
)
[3] => Array (
['name'] => 'name'
['contents'] => 'tester'
)
[4] => Array (
['name'] => 'is_org'
['contents'] => 'N'
)
)
)
// Sending Request using 'POST' Method
$client = new GuzzleHttp\Client();
$response = $client->request('POST','abcdxyz.com',$getRequest);
Now my problem is, The Response which I am receiving after sending the above request says "API 'function_key' is missing".
But I am sending 'function_key' as part of request, then What I am missing here ?? Why it is not able to find 'function_key'
Any help is Appreciated
TIA
Try formating it as follows:
$postRequest = [
'headers' => [
'x-api-key' => 'srDxd39M2FQxxvfvxxcIohcLfKDcdcRUU'
],
'form_params' => [
'function_key' => 'REGISTER',
'email' => 'tester#test.com',
'password' => 'test',
'name' => 'tester',
'is_org' => 'N'
]
]

onwsignal web notification error

actually i am tring to get data from url which i already got but i can't able to insert data into the array please check values are dummy1 dummy2
Array ( [id] => 491 [headings] => ‘సౌందర్య లహరి’ ఎలా ఉంది అంటే..? [content] => శ్రీ వాసు దర్శకత్వం లో బెల... [userPic] => 682473.jpg ) JSON sent: {"app_id":"35fi6c27-5f39-4s9f-94db-79bf123g0f9","included_segments":["All"],"data":{"foo":"bar"},"contents":{"en":"dummy1"},"headings":{"en":"dummy2"},"url":"http:\/\/www.gggg.in\/view.php?id=[id]","chrome_web_image":"http:\/\/www.ggg.in\/admin\/user_images\/[userPic]"} JSON received: {"allresponses":"{\"id\":\"f66a03a4-1b17-8tf3-93ed-f3ad6rt7cdb9\",\"recipients\":6}"}
the above data got from url
http://www.ggg.in/gistfile1.php?id=491&headings=%E2%80%98%E0%B0%B8%E0%B1%8C%E0%B0%82%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%AF%20%E0%B0%B2%E0%B0%B9%E0%B0%B0%E0%B0%BF%E2%80%99%20%E0%B0%8E%E0%B0%B2%E0%B0%BE%20%E0%B0%89%E0%B0%82%E0%B0%A6%E0%B0%BF%20%E0%B0%85%E0%B0%82%E0%B0%9F%E0%B1%87..?&content=%20%E0%B0%B6%E0%B1%8D%E0%B0%B0%E0%B1%80%20%E0%B0%B5%E0%B0%BE%E0%B0%B8%E0%B1%81%20%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%B6%E0%B0%95%E0%B0%A4%E0%B1%8D%E0%B0%B5%E0%B0%82%20%E0%B0%B2%E0%B1%8B%20%E0%B0%AC%E0%B1%86%E0%B0%B2...&userPic=682473.jpg
and i need to insert the values in this function
function sendMessage() {
$content = array(
"en" => 'dummy1'
);
$headings = array(
"en" => 'dummy2'
);
$hashes_array = array();
$fields = array(
'app_id' => "35fi6c27-5f39-4s9f-94db-79bf123g0f9",
'included_segments' => array(
'All'
),
'data' => array(
"foo" => "bar"
),
'contents' => $content,
'headings' => $headings,
'url' => 'http://www.gggg.in/view.php?id=[id]',
'chrome_web_image' => 'http://www.ggg.in/admin/user_images/[userPic]',
);
OneSignal does not support substituting variable data directly into API calls. However, you can achieve this with Tag and Variable Substitution: https://documentation.onesignal.com/docs/personalization
this is the solutions for this Question i asked about
actually i have a varable passing throug url and i need them to insert into function
$array = [
'id' => 498,
'value2' => 'యూట్యూబ్‌లో “భరత్ అనే నేను” అన్ కట్ సీన్లు..!',
'value1' => 'కొరటాల శివ దర్శకత్వం లో సూ...',
'value3' => '525722.jpg'
];
sendMessage($array);
function sendMessage($array) {
$content = array(
"en" => $array['value1']
);
$headings = array(
"en" => $array['value2']
);
$hashes_array = array();
$fields = array(
'app_id' => "31pe2347-5i39-4y9f-2222-79b5875f00f9",
'included_segments' => array(
'All'
),
'data' => array(
"foo" => "bar"
),
'contents' => $content,
'headings' => $headings,
'url' => 'http://w...content-available-to-author-only...9.in/view.php?id=' . $array['id'],
'chrome_web_image' => 'http://w...content-available-to-author-only...9.in/admin/user_images/' . $array['value3'],
);
print_r($fields);
}

laravel-shopify-API-wrapper: Pass charge to shopify

I'm using this shopify api code. I've managed to get my app to install but now when I try to set up a charge for my app when I make the call I get this error:
Exception in api.php line 512:
ERROR #3: <url> malformed
This is my code:
$charge_params = array (
'recurring_application_charge' => array (
'name' => 'Name Of Charge',
'price' => 10,
'return_url' => 'https://dev.shopify.com/show_products/', // also tried escaping the url so https:\/\/dev.shopify.com\/show_products\/
'test' => true
)
);
$charge = $sh->call(['URL' => '/admin/recurring_application_charges.json', 'METHOD' => 'GET', 'DATA' => ['charge_params' => $charge_params]], false);
Can anyone see what I'm doing wrong? I suspect it might be the way the $charge_params is being passed in. There's no documentation on how to pass the charge data through that I can see.
I am just trying to recall what I did on an old project, here is how I handled it, I am using the following package for this https://github.com/phpish/shopify:
$connection = shopify\client($shop, Config::get('shopify.app_api_key'), $token);
$billing = $connection('POST /admin/recurring_application_charges.json', [
'recurring_application_charge' => [
'name' => 'Standard',
'price' => '5.0',
'return_url' => Config::get('app.url') . '/shopify/billing',
'test' => Config::get('shopify.test_mode')
]]);
Not sure if this is any help to you...
Had to pass the full URL and pass the charge array slightly differently. Also changed the method to "POST".
This code did the trick:
$charge = $sh->call([
'URL' => 'https://mystore.myshopify.com/admin/recurring_application_charges.json',
'METHOD' => 'POST',
'DATA' => array (
'recurring_application_charge' => array (
'name' => 'Name Of Charge',
'price' => 10,
'return_url' => 'https://dev.shopify.com/show_products/',
'test' => true
)
)
], false);
print_r($charge);
exit;
This returned the following:
stdClass Object ( [recurring_application_charge] => stdClass Object ( [id] => 2655692 [name] => Name Of Charge [api_client_id] => 1182423 [price] => 10.00 [status] => pending [return_url] => https://dev.shopify.com/show_products/ [billing_on] => [created_at] => 2016-08-03T13:50:11-04:00 [updated_at] => 2016-08-03T13:50:11-04:00 [test] => 1 [activated_on] => [trial_ends_on] => [cancelled_on] => [trial_days] => 0 [decorated_return_url] => https://dev.shopify.com/show_products/?charge_id=2655692 [confirmation_url] => https://mystore.myshopify.com/admin/charges/2655692/confirm_recurring_application_charge?signature=BAhpA8yFKA%3D%3D--8f87b4bd0d3cb9a588dfcb1566572731c0118776 ) )

can someone assist with experiance of the domainbox api and php please

Has anyone had experience with the domainbox.com api? I have never done anything like this before and any help would be really appreciated. What i'm trying to do is using php send the request and bring back the results displaying them on the page but to be honest i don't even know where to start or if this is even the best way to do it.
html
<form action="searchdomain.php" method="post">
domain: <input type="text" name="domainname">
<input type="submit">
</form>
php
<?php
$client = new SoapClient('https://live.domainbox.net/?WSDL', array('soap_version' => SOAP_1_2));
// populate the inputs....
$params = array(
'AuthenticationParameters' => array(
'Reseller' => 'pulseinternet',
'Username' => 'roy_admin',
'Password' => '*********'
),
'CommandParameters' => array(
'DomainName' => '($_POST["domainname"])',
'LaunchPhase' => 'GA'
)
);
$result = $client->CheckDomainAvailability($params, AvailabilityStatus);
print_r($result);
?>
results
stdClass Object ( [CheckDomainAvailabilityResult] => stdClass Object ( [ResultCode] => 250 [ResultMsg] => TLD '' not supported [TxID] => d015865c-b99e-400f-94b9-badf89b0216f [AvailabilityStatus] => 3 [AvailabilityStatusDescr] => ErrorOccurred [LaunchPhase] => GA [DropDate] => [BackOrderAvailable] => [AdditionalResults] => stdClass Object ( ) ) )
Thanks in advance Roy
Here you are a working example:
$dom = 'test12309go.com';
$tld = '.com,.net,.org';
//$client = new SoapClient('https://sandbox.domainbox.net/?WSDL', array('trace' => true, 'soap_version' => SOAP_1_2));
$client = new SoapClient('https://live.domainbox.net/?WSDL', array('trace' => true, 'soap_version' => SOAP_1_2));
$params = array(
'AuthenticationParameters' => array(
'Reseller' => 'MyReseller',
'Username' => 'MyUsername',
'Password' => 'MyPassword'
),
'CommandParameters' => array(
'DomainName' => $dom,
'TLDs' => $tld,
'Limit' => '10',
'CheckAtRegistry' => true,
'DomainCheck' => array(
'Include' => true
),
'NameSuggestions' => array(
'Include' => false
),
'PremiumDomains' => array(
'Include' => false
),
)
);
$result = $client->CheckDomainAvailabilityPlus($params);
//echo $client->__getLastRequest();
print_r($result);

Aramex Rate calculator APT returning error code "ISE01"

The Aramex Rate calculator API is returning the error code ISE01 and and the following error message:
Internal Server Error has occurred while getting calculating rate` while requesting
What it the reason for this error?
The following is the sample code for the Aramex rate calculator API:
<?php
$params = array(
'ClientInfo' => array(
'AccountCountryCode' => 'JO',
'AccountEntity' => 'AMM',
'AccountNumber' => '00000',
'AccountPin' => '000000',
'UserName' => 'user#company.com',
'Password' => '000000000',
'Version' => 'v1.0'
),
'Transaction' => array(
'Reference1' => '001'
),
'OriginAddress' => array(
'City' => 'Amman',
'CountryCode' => 'JO'
),
'DestinationAddress' => array(
'City' => 'Dubai',
'CountryCode' => 'AE'
),
'ShipmentDetails' => array(
'PaymentType' => 'P',
'ProductGroup' => 'EXP',
'ProductType' => 'PPX',
'ActualWeight' => array('Value' => 5, 'Unit' => 'KG'),
'ChargeableWeight' => array('Value' => 5, 'Unit' => 'KG'),
'NumberOfPieces' => 5
)
);
$soapClient = new SoapClient('http://url/to/wsdl.wsdl', array('trace' => 1));
$results = $soapClient->CalculateRate($params);
echo '<pre>';
print_r($results);
die();
?>
Just download WSDL FILE, put it somewhere on your server, and change this line to correct one (fix the url!):
$soapClient = new SoapClient('http://url/to/wsdl.wsdl', array('trace' => 1));
-
Your SOAP Client simply doesn't really recognize CalculateRate command without directions...
PS. Worked for me, just tried.

Categories