I need to create a PHP OData producer supporting both GET and PUT. Up to now I've only found this library, unfortunately this not support PUT operation.
Any suggestions?
Thank's
Currently there's no PHP Library (public) available to support OData CUD (Change, Update and Delete) operations.
Just released. Documentation is coming.
https://packagist.org/packages/falseclock/dbd-php
$cache = DBD\Cache\MemCache::me()->create(array(['host' => '127.0.0.1', 'port' => 11211]),false,"15 min")->open();
$odata_options = array(
'RaiseError' => true,
'PrintError' => true,
'HTMLError' => true,
'CacheDriver' => $cache
);
$od = (new DBD\OData())->create('http://crm.beta.virtex.kz/odata/', "user", "password", $odata_options);
$sth = $od->prepare("
SELECT
Ref_Key, Number, Date
FROM
Document_Invoices
ORDER BY
Date аsc
LIMIT 10
");
$sth->cache('CacheKey','24h');
$sth->execute();
while ($row = $sth->fetchrow()) {
print_r($row);
}
$od->update(
'Document_Invoices',
array('Date' => $data['Date']),
"(guid?)",
$data['Ref_Key'] // for ?-placeholder
);
Related
I have a table in Amazon DynamoDB. I want to get the number of items in the table using PHP script.
Now, I know that there are a lot of questions about this topic, but they are all obsolete, and the solutions use an out-of-date APIs.
I tried running this code, but probably, as I said, it uses an out-of-date API, since it can't find the class:
$dynamodb = new DynamoMetadata();
$scan_response = $dynamodb->scan(array(
'TableName' => 'Table',
'Count' => true
));
echo "Count: ".$scan_response->body->Count."\n";
I also tried with this, but again, it couldn't find the class:
$dynamodb = new AmazonDynamoDB();
I also tried using describeTable, to get ItemCount, but this number isn't updated. It gets updated only every 6 hours.
Is there a way so I could view the number of of items in the table in real-time?
Following solution helped me to get counts using php7 and AWS SDK v3:
<?php
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\DynamoDb\Exception\DynamoDbException;
$sharedConfig = [
'region' => 'us-east-1',
'version' => 'latest',
'DynamoDb' => [
'region' => 'us-east-1'
]
];
$sdk = new Aws\Sdk($sharedConfig);
$client = $sdk->createDynamoDb();
$tableName = '<TABLE NAME>';
$params = [
'TableName' => $tableName,
'Select' => 'COUNT'
];
try {
$result = $client->scan($params);
$count = current($result)['Count'];
echo $count;
} catch (DynamoDbException $e) {
echo "Unable to query:\n";
echo $e->getMessage() . "\n";
}
So, I found a solution:
$result = $client->describeTable(array(
'TableName' => 'errors'
));
// The result of an operation can be used like an array
echo $result['Table']['ItemCount'] . "\n";
But this is not what I wanted...
I need a solution that will show me the number in real-time and not the number which was true 6 hours ago...
Okay, had no luck with the ZETA email client, so now I tried installing the Horde IMAP Client library. I've managed to login to my account, and make a search for e-mails, also got back the results, but I don't know how to fetch the email data, and the documentation is not really helping:|
I presume that I would have to use the Horde_Imap_Client_Base::fetch() method to get some e-mails, which accepts two parameters, a mailbox name, and a Horde_Imap_Client_Fetch_Query object, but I don't know how to get this second object:|
Should this object be returned by one of the Base functions, or should I build this object with the query parameters I want? If the second, how should I rebuild my search query in the fetch query object from the below example?
Here's how I am searching my INBOX, for mails from a specific contact on a specific day:
$client = new Horde_Imap_Client_Socket(array(
'username' => 'my.email#address.com',
'password' => 'xxxxxxxxxx',
'hostspec' => 'my.mail.server',
'port' => '143',
'debug' => '/tmp/foo',
));
$query = new Horde_Imap_Client_Fetch_Query();
$query->dateSearch(new Date(), Horde_Imap_Client_Search_Query::DATE_ON);
$query->headerText("from","mycontact#contact.email");
$results = $client->search('INBOX', $query);
The Horde_Imap_Client_Base::search() returns an array, which contains the search results(the message id's of the searched emails), and some additional data.
Not completely answering your questions. This is how I search for messages which are not deleted.
$client = new Horde_Imap_Client_Socket(array(
'username' => $user,
'password' => $pass,
'hostspec' => $server,
'secure' => 'ssl'
));
$query = new Horde_Imap_Client_Search_Query();
$query->flag(Horde_Imap_Client::FLAG_DELETED, false);
$results = $client->search('INBOX', $query);
foreach($results['match'] as $match) {
$muid = new Horde_Imap_Client_Ids($match);
$fetchQuery = new Horde_Imap_Client_Fetch_Query();
$fetchQuery->imapDate();
$list = $client->fetch('INBOX', $fetchQuery, array(
'ids' => $muid
));
var_dump($list);
}
$results = $client->search($mailbox, $searchquery, array('sort' => array($sSortDir, $sSort)));
$uids = $results['match'];
for ($i = $i_start; $i < $i_to; $i++)
{
$muid = new Horde_Imap_Client_Ids($uids->ids[$i]);
$list = $client->fetch($mailbox, $query, array(
'ids' => $muid
));
$flags = $list->first()->getFlags();
$part = $list->first()->getStructure();
$map = $part->ContentTypeMap();
$envelope = $list->first()->getEnvelope();
}
I am using the following php script in mule. When i am running this php file individually(through wamp) i am able to get the required output.
<?php
$client1=new SoapClient('example/v2_soap?wsdl', array('trace' => 1, 'connection_timeout' => 120));
$username = '******';
$password = '******';
//retreive session id from login
$session = $client1->login(
array(
'username' => $username,
'apiKey' => $password,
)
);
$result= $client1->catalogProductInfo(
array(
'sessionId' => $session->result,
'productId' => 1,
)
);
print_r($result);
return $result;
?>
But i want to run the following script through mule. So when i am running it through mule i am getting the following error.
Root Exception stack trace:
com.caucho.quercus.QuercusErrorException: eval::5: Fatal Error: 'SoapClient' is an unknown class name.
at com.caucho.quercus.env.Env.error(Env.java:4480)
at com.caucho.quercus.env.Env.error(Env.java:4399)
at com.caucho.quercus.env.Env.createErrorException(Env.java:4130)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
It says SoapClient is an unknown class. What is the problem here?
Do i have to include some SoapClient here? If so where can i find it. Please help!!
I'm not sure if mule supports php extensions, but that's what it seems by the error. You could try downloading nusoap into your project,
which doesn't require any php extension. The syntaxis is a little bit different though, but shouldn't be harder to adapt your code.
For what it's worth, this is a simple example of a soap request using nusoap (taken from here http://www.richardkmiller.com/files/msnsearch_nusoap.html):
require_once('nusoap/lib/nusoap.php');
$request = array('Request' => array(
'AppID' => 'MSN_SEARCH_API_KEY',
'Query' => 'Seinfeld',
'CultureInfo' => 'en-US',
'SafeSearch' => 'Strict',
'Flags' => '',
'Location' => '',
'Requests' => array(
'SourceRequest' => array(
'Source' => 'Web',
'Offset' => 0,
'Count' => 50,
'ResultFields' => 'All'))));
$soapClient = new soapclient("http://soap.search.msn.com/webservices.asmx?wsdl", false);
$result = $soapClient->call("Search", $request);
print_r($result);
I hope it helps.
I understand there seems to be a problem with running the soap client inside quercus (rather than Mule).
However instead of focusing on it I would suggest to take a look to the CXF client and the Web services consumer. You are running inside of Mule a powerful opensource ESB, there is no need to write a php script to consume a service, you have all that functinality already present.
I get an array from other website with helping SOAP client, it's quite big array, you can check it out short version here
An array
I need to get category names, my code is here, it works but slows website down. if anyone can provide better code.
$client = new nusoap_client('http://87.253.63.146/b2b/b2bWS?WSDL', 'wsdl');
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$parametrebi = array('user' => '','brand' => '', 'vat_zone' => 'GEVAT', 'currency' => 'GEL', 'all_items' => 'Y', 'page_num' => '1', 'lines_per_page' => '25');
$result = $client->call('GetPriceList', $parametrebi, array('return' => 'xsd:string'), "");
foreach($result['PriceList']['categories']['category'] as $category)
{
echo '<option value="'.$category['!id'].'">'.$category['!name'].'</option>';
}
Do the categories change that often?
Cant you poll for the categories every so often?
Eg every 5 min or so make this soap call and either save the categories to a table in the DB (not such a good idea) or memcache.
http://memcached.org/
If you can use memcache...here is a ruff example:
$memcache_obj = new Memcache();
$memcache_obj->connect('memcache_host', 11211);
if(!$categories = $memcache_obj->get('soap_categories')) {
$client = new nusoap_client('http://87.253.63.146/b2b/b2bWS?WSDL', 'wsdl');
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$parametrebi = array('user' => '','brand' => '', 'vat_zone' => 'GEVAT', 'currency' => 'GEL', 'all_items' => 'Y', 'page_num' => '1', 'lines_per_page' => '25');
$result = $client->call('GetPriceList', $parametrebi, array('return' => 'xsd:string'), "");
$categories = $result['PriceList']['categories']['category'];
$memcache_obj->set('soap_categories', $categories)
}
foreach($categories as $category)
{
echo '<option value="'.$category['!id'].'">'.$category['!name'].'</option>';
}
You can set the expire time on memcache to 1,2,5...ect minuites so the categories will be updated every time the cache expires. Other then when the cache expires the lookup time will be less then 5-10ms.
hello
I have 2 entties in sugar crm
Application
Candidate
Application has a relation with candidate. Now i want enter data using soap api to application with candidate name which is relational field
Please help
My suggestion for SugarCRM 5.5. However, based on the releationship type you defined, it might need some changes.
<?php
require_once 'nusoap.php';
$sugarClient = new soapclient($myUrl, true);
$response = $sugarClient->login(array('user_name' => $myUser, 'password' => md5($myPass), 'version' => '1'), 'myApp');
$sessionId = $response['id'];
$response = $sugarClient->get_entry_list($sessionId, 'Applications', 'name = '. $myValue, $myOrderBy, 0, array('id'));
$applicationId = $response['entry_list'][0]['id'];
$myCandidate = array(array('key' => $myVal1, 'key2' => $myVal2));
$response = $sugarClient->set_entry($sessionId, $myCandidate);
$candidateId = $response['id'];
$myRelation = array('module1' => 'Candidates', 'module1_id' => $candidateId, 'module2' => 'Applications', 'module2_id' => $applicationId);
$sugarClient->set_relationship($sid, $myRelation);
$sugarClient->logout($sessionId);
?>
For more info see: http://www.sugarcrm.com/crm/support/documentation/SugarCommunityEdition or search google for some examples.