Unable to get Salesforce SOAP API to create in PHP8.1 - php

I've been using the Salesforce SOAP API for a number of years, but the original PHP client that Salesforce provided doesn't work with PHP8.1. I've attempted to incorporate the necessary elements of the client into my code since I'm only performing one simple action (creating a QuoteLineItem). I've been able to get the client to properly connect and login, but my create command doesn't get any response (not even a NULL value).
I've compared everything being sent from the PHP7.4 solution and my 8.1 implementation, and they appear almost identical.
Create statement:
$result = $this->sforcePartnerClient->create($arg);
$arg value:
object(stdClass)#1331 (2) { ["__CLASS__"]=> string(8) "stdClass" ["sObjects"]=> array(1) { [0]=> string(26) "\Module\Controller\SObject" } }
Why am I not getting even an error response?

Related

GET attribute are ignore while requesting data from WooCommerce REST API

I have a CRM set to crm.example.com And a active store on example.com (on the same server)
Both running with NGINX.
Im trying to request the whole categories list (43 categories) but i'm getting only 10. (The default value set by WooCommerce).
I tried using the per_page parameter but it seems like the server is ignore the GET.
I checked the request sent from crm.example.com and got that:
object(Automattic\WooCommerce\HttpClient\Request)#85 (5) {
["url":"Automattic\WooCommerce\HttpClient\Request":private]=>
string(67) "https://example.com/wp-json/wc/v2/products/categories/?per_page=100"
["method":"Automattic\WooCommerce\HttpClient\Request":private]=>
string(3) "GET"
["parameters":"Automattic\WooCommerce\HttpClient\Request":private]=>
array(1) {
["per_page"]=>
int(100)
}
["headers":"Automattic\WooCommerce\HttpClient\Request":private]=>
array(2) {
["Accept"]=>
string(16) "application/json"
["User-Agent"]=>
string(32) "WooCommerce API Client-PHP/1.3.0"
}
["body":"Automattic\WooCommerce\HttpClient\Request":private]=>
string(0) ""
}
But yet there is only 10 results.
i'm thinking maybe the NGINX server is ignoring the GET parameters as a security policy?

Download media object in PHPRETS

Background Information
I want to download photos of a specific property using PHPRETS.
My PHPRETS configuration works successfully for downloading property data. The problem is only with downloading media files.
I am able to download photos of the property using RETS Connector, the Windows application, meaning the images exist.
The value that I pass as the object key (N3273704) is the value that I've got from the KeyField (ml_num)
KeyField
ml_num
The code I run
$photos = $rets->GetObject("Property", "Photo", "N3273704", "*", 0);
var_dump($photos);
foreach ($photos as $photo) {
$listing = $photo['Content-ID'];
$number = $photo['Object-ID'];
if ($photo['Success'] == true) {
file_put_contents("image-{$listing}-{$number}.jpg", $photo['Data']);
} else {
echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
}
}
Raw header and response
[2015-07-29 13:16:09] PHRETS.DEBUG: Sending HTTP Request for http://rets.torontomls.net:6103/rets-treb3pv/server/getobject (GetObject) {"query":{"Resource":"Property","Type":"Photo","ID":"N3273704:*","Location":0},"headers":{"User-Agent":"PHRETS/2.0","RETS-Version":"RETS/1.5","Accept-Encoding":"gzip"},"cookies": ..."]} []
[2015-07-29 13:16:09] PHRETS.DEBUG: Response: HTTP 200 [] []
Output on screen (result of var_dump)
array(20) {
[0]=>
object(PHRETS\Models\Object)#32 (10) {
["content_type":protected]=>
string(8) "text/xml"
["content_id":protected]=>
string(4) "null"
["object_id":protected]=>
string(4) "null"
["mime_version":protected]=>
NULL
["location":protected]=>
NULL
["content_description":protected]=>
NULL
["content_sub_description":protected]=>
NULL
["content":protected]=>
string(192) "<?xml version="1.0" standalone="no"?>
<!DOCTYPE RETS SYSTEM "RETS-20041001.dtd">
<RETS ReplyCode="20403" ReplyText="No Object Found: No matching object was found to satisfy the request."/>"
["preferred":protected]=>
NULL
["error":protected]=>
object(PHRETS\Models\RETSError)#45 (2) {
["code":protected]=>
int(20403)
["message":protected]=>
string(69) "No Object Found: No matching object was found to satisfy the request."
}
}
[1]=> ...
I was able to figure out the issue and I'm writing this in the hope it saves somebody's time.
After monitoring HTTP traffic and comparing raw headers sent from PHRETS and RETS connector, the Windows application, it turned out that some RETS servers (in this case, Toronto Real Estate Board) require the "Accept" field to be present in the header. So, the problem is solved by adding the following line to the constructor of Session class:
'Accept' => '*/*',
I wanted to contribute one note... TREB has the KeyField misconfigured. They are using the DBName version of the Property's identifying field (ml_num), whereas the KeyField is supposed to be the SystemName version of that field (Ml_num).... just a matter of difference in case, but enough to be a breaking change for RETS clients that would derive the KeyField automatically from the RETS metadata.

Unable to POST data from mobile App to Laravel 4 Application

I have an android application which sends some data in a POST request to my web application built with Laravel 4. I tried testing the web application by sending a crafted POST request from the REST Console chrome extension. I have used Resource routing in my application, and so in the "store" method of the controller, I tried to get the POST data using Input::get("key"). This however gives me "null" . Even Input::all() returns null.
Can someone help me figure out how I can achieve this. I cannot use Model binding directly, as I need to perform some validation on the data before storing it.
$request = Request::instance();
$content = $request->getContent();
dd($content);
This snippet printed out the data that has been passed out via POST viz. string(25) "test=12121&variable=12123".
Weirdly enuff dd($_POST) gave array(0) {}

Buddy online status using FreeSWITCH's mod_skypopen and PHP

I am new to FreeSWITCH/Skypopen. I need to get the the status of a buddy using the skypopen module and PHP.
I am using the following PHP script to get the status.
<?php
$output = array();
$returnVar = "";
$result = exec('fs_cli -x "skypopen interface1 GET USER skypeusername ONLINESTATUS"', $returnVar, $output);
var_dump($result, $returnVar, $output);
?>
After executing the PHP file, I get the following response:
string(0) ""
array(2) {
[0]=>
string(68) "Using interface: globals.SKYPOPEN_INTERFACES[18].name=|||interface1|||"
[1]=>
string(0) ""
}
int(0)
It only returns Using interface: globals.SKYPOPEN_INTERFACES[18].name=|||interface1|||, not the online status of "skypeusername".
But if I execute the command skypopen interface1 GET USER skypeusername ONLINESTATUS in FreeSWITCH CLI, it returns the following:
freeswitch#internal> skypopen interface1 GET USER skypeusername ONLINESTATUS
Using interface: globals.SKYPOPEN_INTERFACES[18].name=|||interface1|||
2013-06-04 04:06:35.778928 [DEBUG] skypopen_protocol.c:1771 [1a3a11f|3d6ed64] [DEBUG_SKYPE 1771 ][interface1 ][IDLE,IDLE] SENDING: |||GET USER skypeusername ONLINESTATUS||||
2013-06-04 04:06:35.778928 [DEBUG] skypopen_protocol.c:209 [1a3a11f|3d6ed64] [DEBUG_SKYPE 209 ][interface1 ][IDLE,IDLE] READING: |||USER skypeusername ONLINESTATUS ONLINE|||
After doing some search in Google, I found that the skypopen module sends the result to its log file as DEBUG log.
Is there a way to get that response as result to the PHP script?
Skypopen module has a problem. So it does not return response to socket or cli. It returns to log only. You need to modify code to send response to socket and you will get it on php end.
I don't have this module loaded, but judging by the source code of the skypopen_function in mod_skypopen.c, it seems that the skypopen API calls never really return anything except for the interfaces line that you mentioned.
On the other hand, it looks like the module fires a skypopen::incoming_raw event every time it receives data from the Skype API, so you could try opening an ESL connection from PHP and listening for these.
You should first try it directly on fs_cli:
freeswitch#internal> /event plain CUSTOM skypopen::incoming_raw
Then:
freeswitch#internal> skypopen interface1 GET USER skypeusername ONLINESTATUS

simplexml_load_file works on a local machine, doesn't work online

I'm using Deezer APIs
$xml = simplexml_load_file('http://api.deezer.com/2.0//search/artist/?q=eminem&index=0&nb_items=1&output=xml');
var_dump($xml);
$xml = simplexml_load_file('http://api.deezer.com/2.0/artist/393/top/&output=xml');
var_dump($xml);
The first call works in the same way both on my local machine (Mac PHP 5.3.15) and online on a dream-host server (PHP 5.3.13), the second call works on my local machine, reporting all 5 track objects, but not on-line, where I just get
object(SimpleXMLElement)#4 (2) {
["data"]=> object(SimpleXMLElement)#1 (0) { }
["total"]=> object(SimpleXMLElement)#3 (0) { }
}
It seems to me very weird, do you have any clue?
Thanks
Deezer use geolocation for Artist Request.
So, if your server is geolocated in US for example, the first request have the same result between local and online but de second one (http://api.deezer.com/2.0/artist/393/top/&output=xml) don't have the same result local/online.
Request with FR Ip :
<?xml version="1.0" encoding="utf-8"?><root><data><track><id><![CDATA[2114267]]></id><readable><![CDATA[1]]></readable><title><![CDATA[My Life]]></title><link><![CDATA[http://www.deezer.com/track/2114267]]></link><duration><![CDATA[321]]></duration><rank><![CDATA[674751]]></rank><preview><![CDATA[http://cdn-preview-2.deezer.com/stream/2ecb4b24f51cdbfdaea89630f1978529-0.mp3]]></preview><artist><id><![CDATA[393]]></id><name><![CDATA[The Game]]></name></artist><type><![CDATA[track]]></type></track><track><id><![CDATA[2307182]]></id><readable><![CDATA[1]]></readable><title><![CDATA[Hate It Or Love It]]></title><link><![CDATA[http://www.deezer.com/track/2307182]]></link><duration><![CDATA[207]]></duration><rank><![CDATA[654207]]></rank><preview><![CDATA[http://cdn-preview-3.deezer.com/stream/393350005d03712abc9adfbe2bcfe2d3-0.mp3]]></preview><artist><id><![CDATA[393]]></id><name><![CDATA[The Game]]></name></artist><type><![CDATA[track]]></type></track><track><id><![CDATA[2294433]]></id><readable><![CDATA[1]]></readable><title><![CDATA[How We Do]]></title><link><![CDATA[http://www.deezer.com/track/2294433]]></link><duration><![CDATA[235]]></duration><rank><![CDATA[610398]]></rank><preview><![CDATA[http://cdn-preview-c.deezer.com/stream/c3683a1fc1899c9d1b128b222d0e080f-1.mp3]]></preview><artist><id><![CDATA[393]]></id><name><![CDATA[The Game]]></name></artist><type><![CDATA[track]]></type></track><track><id><![CDATA[62751648]]></id><readable><![CDATA[1]]></readable><title><![CDATA[Ali Bomaye]]></title><link><![CDATA[http://www.deezer.com/track/62751648]]></link><duration><![CDATA[373]]></duration><rank><![CDATA[571988]]></rank><preview><![CDATA[http://cdn-preview-1.deezer.com/stream/1bb2606c722235eeecb2b1caa039f5c1-0.mp3]]></preview><artist><id><![CDATA[393]]></id><name><![CDATA[The Game]]></name></artist><type><![CDATA[track]]></type></track><track><id><![CDATA[61571949]]></id><readable><![CDATA[1]]></readable><title><![CDATA[Celebration]]></title><link><![CDATA[http://www.deezer.com/track/61571949]]></link><duration><![CDATA[290]]></duration><rank><![CDATA[559639]]></rank><preview><![CDATA[http://cdn-preview-f.deezer.com/stream/f1f535359bd60ce3ec77d59fcfda4ebd-1.mp3]]></preview><artist><id><![CDATA[393]]></id><name><![CDATA[The Game]]></name></artist><type><![CDATA[track]]></type></track></data><total><![CDATA[5]]></total></root>
The same request with US location :
<?xml version="1.0" encoding="utf-8"?><root><data></data><total><![CDATA[0]]></total></root>
To complete the answer. You can change Geolocation of your request (and have result from US Server) with access_token of user located in non-restricted country because when you request the deezer api with access_token, the api will use the user country and not the server country.
To get an access token from user :
http://developers.deezer.com/api/oauth
Don't forget on each request when you want to use the User geolocation to add this :
?access_token=XXXXX
EDIT :
I am part of the deezer team.
if you want to access xml by http protocol you will need to set allow_url_fopen ON in php.ini or
ini_set('allow_url_fopen ','ON');
in your code. or you can also do this if you are using php version <5
$temp = file_get_contents($url);
$XmlObj = simplexml_load_string($temp);
try:
$xml = simplexml_load_file('http://api.deezer.com/2.0/artist/393/top/?output=xml');
(i.e. change the '&' to '?')
This may or may not be the problem.

Categories