PHP Classes

Issue with arrays in paramaters

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  Issue with arrays in paramaters  >  (Un) Subscribe thread alerts  
Subject:Issue with arrays in paramaters
Summary:Problem passing arrays inside of callapi -> parameters
Messages:6
Author:Greg Davault
Date:2015-05-07 22:29:14
 

  1. Issue with arrays in paramaters   Reply   Report abuse  
Picture of Greg Davault Greg Davault - 2015-05-07 22:29:14
I use etsy. I need to pass a set of parameters to the callapi. The parameters include 2 string arrays in it. When passing the arrays, I receive a oauth_problem => signature_invalid and a notice: Array to string conversion in oauth_client.php on line 1397. When I do not pass the 2 arrays, everything is ok. Is there anything special I need to do to pass arrays inside of parameters? Thanks

Greg

  2. Re: Issue with arrays in paramaters   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-05-07 22:58:37 - In reply to message 1 from Greg Davault
Can you provide minimal sample code that I can use to reproduce that problem?

  3. Re: Issue with arrays in paramaters   Reply   Report abuse  
Picture of Greg Davault Greg Davault - 2015-05-07 23:37:17 - In reply to message 2 from Manuel Lemos
I am trying to create a new listing in etsy. Let me know if you need anything else.By the way, thanks for creating PHP oauth API. It has been a blessing. Greg


if($result = $mysql1->query($strsql)){
$rows = mysqli_fetch_all($result,MYSQLI_ASSOC);
foreach ($rows as $row){
echo "A listing for:{$row["Name"]} is being created. <br>";
$listing = array();
$listing["quantity"] = $row["QuantityOnHand"];
$listing["title"] = $row["ItemTitlePlainText"];
$listing["price"] = strip_tags($row["SalesPrice"]);
if ($row["Material"] == NULL) {}
else {
$material = array($row["Material"]);
$listing["materials"] = $material;
}
$listing["shipping_template_id"] = 12220652943;
if ($row["Shop_Section_Etsy"] == NULL) {}
else {
$listing["shop_section_id"] = $row["Shop_Section_Etsy"];
}
$listing["is_customizable"] = "false";
$listing["non_taxable"] = "false";
$listing["state"] = "draft";
$listing["processing_min"] = 1;
$listing["processing_max"] = 3;
$listing["taxonomy_id"] =$row["CategoryEtsy"];
//$listing = array("tags" => $row["CategoryEtsy"]);
if ($row["WhoMadeEtsy"] == NULL) {
$listing["who_made"] = "someone_else";
}
else {
$listing["who_made"] = $row["WhoMadeEtsy"];
}
$listing["is_supply"] = "false";
$listing["when_made"] = $row["WhenMadeEtsy"];
if ($row["RecipientEtsy"] == NULL) {
$listing["recipient"] = "unisex_adults";
}
else {
$listing["recipient"] = $row["RecipientEtsy"];
}
if ($row["OccasionEtsy"] == NULL) {}
else {
$listing["occasion"] = $row["OccasionEtsy"];
}
/*if ($row[""] == NULL) {}
else {
$listing["style"] = $row[""];
}*/
$tags = parse_tags($row["TagsEtsy"]);
if (count($tags) < 20 and $row["Brand"]) {
array_push($tags,$row["Brand"]);
}
if (count($tags) < 20 and $row["Author"]) {
array_push($tags,$row["Author"]);
}
if (count($tags) < 20 and $row["YearPublished"]) {
array_push($tags,$row["YearPublished"]);
}
if (count($tags) < 20 and $row["Size"]) {
array_push($tags,"Size ".$row["Size"]);
}
if (count($tags) < 20 and $row["Material"]) {
array_push($tags,$row["Material"]);
}
if (count($tags) < 20 and $row["Publisher"]) {
array_push($tags,$row["Publisher"]);
}
if (count($tags) < 20 and $row["ISBN"]) {
array_push($tags,$row["ISBN"]);
}
if (count($tags) < 20 and $row["ISBN13"]) {
array_push($tags,$row["ISBN13"]);
}
if (count($tags) < 20 and $row["Kind"]) {
array_push($tags,$row["Kind"]);
}
if (count($tags) < 20 ) {
array_push($tags,'Davault Emporium');
}
if (count($tags) < 20 ) {
array_push($tags,'vintage');
}
if (count($tags) < 20 ) {
array_push($tags,'antique');
}
if (count($tags) < 20 ) {
array_push($tags,'collectible');
}
//$listing["tags"] = $tags;
$description = $row["ProductDescriptionPlainText"];
if ($row["Condition"]){
$description = $description."\r\n \r\n Condition:".$row["Condition"];
}
if ($row["Brand"]){
$description = $description."\r\n \r\n Brand:".$row["Brand"];
}
if ($row["Color"]){
$description = $description."\r\n \r\n Color:".$row["Color"];
}
if ($row["Material"]){
$description = $description."\r\n \r\n Material:".$row["Material"];
}
if ($row["Dimensions"]){
$description = $description."\r\n \r\n Dimensions:".$row["Dimensions"];
}
if ($row["Size"]){
$description = $description."\r\n \r\n Size:".$row["Size"];
}
if ($row["Width"]){
$description = $description."\r\n \r\n Width:".$row["Width"];
}
if ($row["Weight"]){
$description = $description."\r\n \r\n Weight(lbs.):".$row["Weight"];
}
if ($row["Style"]){
$description = $description."\r\n \r\n Style:".$row["Style"];
}
if ($row["Gender"]){
$description = $description."\r\n \r\n Gender:".$row["Gender"];
}
if ($row["Author"]){
$description = $description."\r\n \r\n Author:".$row["Author"];
}
if ($row["Publisher"]){
$description = $description."\r\n \r\n Publisher:".$row["Publisher"];
}
if ($row["YearPublished"]){
$description = $description."\r\n \r\n Year Published:".$row["YearPublished"];
}
if ($row["Edition"]){
$description = $description."\r\n \r\n Edition:".$row["Edition"];
}
if ($row["ISBN"]){
$description = $description."\r\n \r\n ISBN:".$row["ISBN"];
}
if ($row["ISBN13"]){
$description = $description."\r\n \r\n ISBN 13:".$row["ISBN13"];
}
if ($row["MediaType"]){
$description = $description."\r\n \r\n Classification:".$row["MediaType"];
}

$listing["description"] = $description;



echo '<pre>', HtmlSpecialChars(print_r($listing, 1)), '</pre>';

$success1 = $client->CallAPI(
'https://openapi.etsy.com/v2/listings/',
'POST', $listing, array('FailOnAccessError'=>true), $return);

  4. Re: Issue with arrays in paramaters   Reply   Report abuse  
Picture of Greg Davault Greg Davault - 2015-05-08 23:02:29 - In reply to message 2 from Manuel Lemos
Looks like I may have found the issue, but still working on it. The etsy docs call for passing arrays. But what they actually want is a comma-delimited string.

  5. Re: Issue with arrays in paramaters   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-05-09 02:58:33 - In reply to message 4 from Greg Davault
So, you managed to make it work, or is there an issue with the class?

  6. Re: Issue with arrays in paramaters   Reply   Report abuse  
Picture of Greg Davault Greg Davault - 2015-05-09 20:11:44 - In reply to message 5 from Manuel Lemos
No, your api is working fine. Even though the etsy documentation defines some parameters as array type, it actually accepts a comma delimited string. Thanks for your help.