what am i doing wrong here?! It's two days since i've killed Google and stackoverflow... I can't figure it out :(((
I've checked online the returned body json (didn't paste it here cause it's long) and is a valid json... where is the problem?!
No cache plugins installed, same request in postman returns an OK result, testing the request URL directly in browser returns an ok result, everyting is fine except when im using in my project...
Automattic\WooCommerce\HttpClient\HttpClientException Object
(
[request:Automattic\WooCommerce\HttpClient\HttpClientException:private] => Automattic\WooCommerce\HttpClient\Request Object
(
[url:Automattic\WooCommerce\HttpClient\Request:private] => https://www.viatainrawz.ro/wp-json/wc/v3/products
[method:Automattic\WooCommerce\HttpClient\Request:private] => GET
[parameters:Automattic\WooCommerce\HttpClient\Request:private] => Array
(
)
[headers:Automattic\WooCommerce\HttpClient\Request:private] => Array
(
[Accept] => application/json
[Content-Type] => application/json
[User-Agent] => WooCommerce API Client-PHP/1.0.2
)
[body:Automattic\WooCommerce\HttpClient\Request:private] =>
)
[response:Automattic\WooCommerce\HttpClient\HttpClientException:private] => Automattic\WooCommerce\HttpClient\Response Object
(
[code:Automattic\WooCommerce\HttpClient\Response:private] => 200
[headers:Automattic\WooCommerce\HttpClient\Response:private] => Array
(
[date] => Mon, 31 Aug 2020 09:26:42 GMT
[content-type] => application/json; charset=UTF-8
[vary] => Accept-Encoding
[x-robots-tag] => noindex
[x-content-type-options] => nosniff
[access-control-expose-headers] => X-WP-Total, X-WP-TotalPages, Link
[access-control-allow-headers] => Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type
[expires] => Wed, 11 Jan 1984 05:00:00 GMT
[cache-control] => no-cache, must-revalidate, max-age=0
[x-wp-total] => 49
[x-wp-totalpages] => 5
[link] => <https://viatainrawz.ro/wp-json/wc/v3/products?page=2>; rel="next"
[allow] => GET, POST
[server] => ClausWeb-nginx
[cluster-host] => server46.romania-webhosting.com
)
)
[message:protected] => Invalid JSON returned
[string:Exception:private] =>
[code:protected] => 200
[file:protected] => /home/vreaumob/worker.vreaumobila.ro/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php
[line:protected] => 303
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /home/vreaumob/worker.vreaumobila.ro/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php
[line] => 346
[function] => lookForErrors
[class] => Automattic\WooCommerce\HttpClient\HttpClient
[type] => ->
[args] => Array
(
[0] =>
)
)
[1] => Array
(
[file] => /home/vreaumob/worker.vreaumobila.ro/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php
[line] => 382
[function] => processResponse
[class] => Automattic\WooCommerce\HttpClient\HttpClient
[type] => ->
[args] => Array
(
)
)
[2] => Array
(
[file] => /home/vreaumob/worker.vreaumobila.ro/vendor/automattic/woocommerce/src/WooCommerce/Client.php
[line] => 82
[function] => request
[class] => Automattic\WooCommerce\HttpClient\HttpClient
[type] => ->
[args] => Array
(
[0] => products
[1] => GET
[2] => Array
(
)
[3] => Array
(
)
)
)
[3] => Array
(
[file] => /home/vreaumob/worker.vreaumobila.ro/apitest.php
[line] => 24
[function] => get
[class] => Automattic\WooCommerce\Client
[type] => ->
[args] => Array
(
[0] => products
)
)
)
[previous:Exception:private] =>
)
Invalid JSON returned
The code i use:
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
use Automattic\WooCommerce\HttpClient\HttpClientException;
try {
$woocommerce = new Client( 'https://www.viatainrawz.ro','XX', 'XX',
[
'verify_ssl' => false,
'version' => 'wc/v3'
]
);
print_r($woocommerce->get('products'));
} catch (HttpClientException $e) {
\print_r($e);
\print_r($e->getMessage() . PHP_EOL);
\print_r('Code: ' . $e->getResponse()->getCode() . PHP_EOL);
\print_r('Body: ' . $e->getResponse()->getBody() . PHP_EOL);
}
Related
In controller i have:
return response()->json(
[
'number' => (float)8
],
Response::HTTP_OK,
[],
JSON_PRESERVE_ZERO_FRACTION
);
This is output:
{
"number": 8
}
Is it possible to get 8.0?
This working good:
json_encode(['number' => (float)8],JSON_PRESERVE_ZERO_FRACTION);
UPDATE:
when i set response()->json from above to $variable and then print_r($variable) i get this:
(so it looks like it working, but with return in browser i get still 8 not 8.0)
Illuminate\Http\JsonResponse Object
(
[data:protected] => {"number":8.0}
[callback:protected] =>
[encodingOptions:protected] => 1024
[headers] => Symfony\Component\HttpFoundation\ResponseHeaderBag Object
(
[computedCacheControl:protected] => Array
(
[no-cache] => 1
[private] => 1
)
[cookies:protected] => Array
(
)
[headerNames:protected] => Array
(
[cache-control] => Cache-Control
[date] => Date
[content-type] => Content-Type
)
[headers:protected] => Array
(
[cache-control] => Array
(
[0] => no-cache, private
)
[date] => Array
(
[0] => Thu, 08 Feb 2018 11:27:34 GMT
)
[content-type] => Array
(
[0] => application/json
)
)
[cacheControl:protected] => Array
(
)
)
[content:protected] => {"number":8.0}
[version:protected] => 1.0
[statusCode:protected] => 200
[statusText:protected] => OK
[charset:protected] =>
[original] => Array
(
[number] => 8
)
[exception] =>
)
Use number_format():
json_encode(['number' => number_format(8, 1)]);
If number is coming as a string, use (float)$stringNumber instead of $stringNumber
Having a spam problem when I send the emails directly from my server, I asked my client to open an email account on her server.
I used smtp authentication with email address and email password.
Here is the detailed answer of the server, can anybody explain me the reason that I cannot send and the solution please.
Thank you.
PEAR_Error Object
(
[error_message_prefix] =>
[mode] => 1
[level] => 1024
[code] => 10006
[message] => Failed to send data [SMTP: Invalid response code received from
server (code: 550, response: 5.7.1 Rejected by spam filter (17211ed8-34a9-
11e7-9a8c-336c9f1d8145) [CSP-02])]
[userinfo] =>
[backtrace] => Array
(
[0] => Array
(
[file] => /opt/cpanel/ea-php56/root/usr/share/pear/PEAR.php
[line] => 577
[function] => __construct
[class] => PEAR_Error
[type] => ->
[args] => Array
(
[0] => Failed to send data [SMTP: Invalid response
code received from server (code: 550, response: 5.7.1 Rejected by spam
filter (17211ed8-34a9-11e7-9a8c-336c9f1d8145) [CSP-02])]
[1] => 10006
[2] => 1
[3] => 1024
[4] =>
)
)
[1] => Array
(
[function] => _raiseError
[class] => PEAR
[type] => ::
[args] => Array
(
[0] =>
[1] => Failed to send data [SMTP: Invalid response
code received from server (code: 550, response: 5.7.1 Rejected by spam
filter
(17211ed8-34a9-11e7-9a8c-336c9f1d8145) [CSP-02])]
[2] => 10006
)
)
[2] => Array
(
[file] => /opt/cpanel/ea-php56/root/usr/share/pear/PEAR.php
[line] => 237
[function] => call_user_func_array
[args] => Array
(
[0] => Array
(
[0] => PEAR
[1] => _raiseError
)
[1] => Array
(
[0] =>
[1] => Failed to send data [SMTP: Invalid
response code received from server (code: 550, response: 5.7.1 Rejected by
spam filter (17211ed8-34a9-11e7-9a8c-336c9f1d8145) [CSP-02])]
[2] => 10006
)
)
)
[3] => Array
(
[file] => /opt/cpanel/ea-
php56/root/usr/share/pear/Mail/smtp.php
[line] => 319
[function] => __callStatic
[class] => PEAR
[type] => ::
[args] => Array
(
[0] => raiseError
[1] => Array
(
[0] => Failed to send data [SMTP: Invalid
response code received from server (code: 550, response: 5.7.1 Rejected by
spam filter (17211ed8-34a9-11e7-9a8c-336c9f1d8145) [CSP-02])]
[1] => 10006
)
)
)
[4] => Array
(
[file] => /opt/cpanel/ea-
php56/root/usr/share/pear/Mail/smtp.php
[line] => 319
[function] => raiseError
[class] => PEAR
[type] => ::
[args] => Array
(
[0] => Failed to send data [SMTP: Invalid response
code received from server (code: 550, response: 5.7.1 Rejected by spam
filter (17211ed8-34a9-11e7-9a8c-336c9f1d8145) [CSP-02])]
[1] => 10006
)
)
[5] => Array
(
[file] => crm/public_html/testsendemail.php
[line] => 22
[function] => send
[class] => Mail_smtp
[object] => Mail_smtp Object
(
[_smtp] => Net_SMTP Object
(
[host] => xxx.com
[port] => 25
[localhost] => localhost
[auth_methods] => Array
(
[LOGIN] => Array
(
[0] => Net_SMTP Object
*RECURSION*
[1] => authLogin
)
[PLAIN] => Array
(
[0] => Net_SMTP Object
*RECURSION*
[1] => authPlain
)
)
[pipelining] =>
[pipelined_commands:protected] => 0
[debug:protected] =>
[debug_handler:protected] =>
[socket:protected] => Net_Socket Object
(
[fp] => Resource id #7
[blocking] => 1
[persistent] =>
[addr] => xxx.com
[port] => 25
[timeout] =>
[lineLength] => 2048
[newline] =>
[_debug] =>
[_default_error_mode] =>
[_default_error_options] =>
[_default_error_handler] =>
[_error_class] => PEAR_Error
[_expected_errors] => Array
(
)
)
[socket_options:protected] => Array
(
)
[timeout:protected] => 0
[code:protected] => 250
[arguments:protected] => Array
(
[0] => Reset OK
)
[greeting:protected] =>
sunucu.alvagenyazilim.com ESMTP Exim 4.86 Tue, 09 May 2017 14:17:29 +0300
[esmtp:protected] => Array
(
[sunucu.alvagenyazilim.com] => Hello
localhost [89.19.23.154]
[SIZE] => 53477376
[8BITMIME] =>
[AUTH] => PLAIN LOGIN
[HELP] =>
)
)
[_extparams] => Array
(
)
[host] => xxx.com
[port] => 25
[auth] => 1
[username] => crm#xxx.com
[password] => Tansudemir12345
[localhost] => localhost
[timeout] =>
[debug] =>
[persist] =>
[pipelining] =>
[socket_options] => Array
(
)
[sep] =>
[greeting] => sunucu.alvagenyazilim.com ESMTP Exim 4.86 Tue, 09 May 2017 14:17:29 +0300
)
[type] => ->
[args] => Array
(
[0] => ozer#rrrr.com
[1] => Array
(
[From] => crm#xxx.com
[To] => ozer#rrrr.com
[Subject] => testemail
[Content-type] => text/html; charset=UTF-8
)
[2] => testemail
)
)
)
[callback] =>
)
)
You should add spf and DKIM records in your DNS zone of the domain and also add rDNS record. once done allow it to propagate and check if the mails are still going to spam folder.
I am trying to get a result in view returned as array in controller.This is a result of an api call using the json.
I need to display the results in the view. There is design integrated in view to display it.
How could i do it in CodeIgniter?
Function call:
$data['nearme_values'] = $this->swsdk->nearMe($lat, $lon, $radius, $page, $size);
This is the var_dumb result of the function call.
stdClass Object
( [content] => Array
( [0] => stdClass Object
( [id] => 1 [name] => Make America Great
[screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/streamSShot/stream-1479113014667.jpg
[type] => PUBLIC [status] => RECORDED [userId] => 1 [userHandle] => abhilekh
[channelId] => 1 [channelName] => Sports [likes] => 0 [views] => 0
[liveViewers] => 0
)
[1] => stdClass Object
( [id] => 2 [name] => Make America Great
[screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/streamSShot/stream-1479110563909.jpg
[type] => PUBLIC [status] => RECORDED [userId] => 1 [userHandle] => abhilekh
[channelId] => 2 [channelName] => Politics [likes] => 0 [views] => 0
[liveViewers] => 0
)
[2] => stdClass Object
( [id] => 3 [name] => Make America Great
[screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/streamSShot/stream-1479109601008.jpg
[type] => PUBLIC [status] => RECORDED [userId] => 2 [userHandle] => sudhanshu
[channelId] => 3 [channelName] => Fun [likes] => 0 [views] => 0
[liveViewers] => 0
)
[3] => stdClass Object
( [id] => 4 [name] => Make America Great
[screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/profiles/pic-130.jpg
[type] => PUBLIC [status] => RECORDED [userId] => 2 [userHandle] => sudhanshu
[channelId] => 4 [channelName] => Art [likes] => 0 [views] => 0
[liveViewers] => 0
)
) [last] => 1 [totalPages] => 1 [totalElements] => 4
[numberOfElements] => 4 [sort] => [first] => 1
[size] => 10 [number] => 0
)
I am new to the CodeIgniter. Please support with sample code.
if you are gonna call as API, no need to put in view.
Just echo like this in controller's method.
$nearme_values = $this->swsdk->nearMe($lat,$lon,$radius,$page,$size);
echo json_encode($nearme_values);
Displaying in View.
// in Controller.
$data['nearme_values'] = $this->swsdk->nearMe($lat, $lon, $radius, $page, $size);
$this->load->view('ur_view_file', $data);
// in view
foreach ($nearme_values->content as $nearme) {
echo $nearme->id .' / '. $nearme->screenShotUrl .' / '. $nearme->type .'<br>';
}
Problem
I made a request to Facebook's Ad Set API attempting to create an ad set with the following JSON blob, and the error I received was "Your Budget Is Too Low. The minimum budget for this ad set is $32.04."
The ad set is set to use auto_bid and a valid lifetime_target. The ad set runs for 31 days, and with a $1 minimum daily budget, setting $64 for lifetime budget should've been sufficient.
Attempted Solutions
I tried to set a higher lifetime budget: from 64 to 1000 to 5000. 1000 did not work in this case, but 5000 did.
JSON Blob Used
Array
(
[account_id] =>
[adset_schedule] =>
[bid_amount] =>
[billing_event] => IMPRESSIONS
[budget_remaining] =>
[campaign_id] => 6054825216096
[created_time] =>
[creative_sequence] =>
[daily_budget] =>
[end_time] => 2016-11-08T07:59:59+0000
[id] =>
[is_autobid] => 1
[lifetime_budget] => 64
[lifetime_imps] =>
[name] => Some-Test-Campaign
[optimization_goal] => LINK_CLICKS
[pacing_type] =>
[recommendations] =>
[rf_prediction_id] =>
[start_time] => 2016-10-07T07:00:00+0000
[updated_time] =>
[targeting] => FacebookAds\Object\TargetingSpecs Object
(
[data:protected] => Array
(
[genders] =>
[age_min] =>
[age_max] =>
[geo_locations] => Array
(
[zips] => Array
(
[0] => Array
(
[key] => US:98004
)
[1] => Array
(
[key] => US:98005
)
[2] => Array
(
[key] => US:98006
)
[3] => Array
(
[key] => US:98007
)
[4] => Array
(
[key] => US:98008
)
[5] => Array
(
[key] => US:98009
)
[6] => Array
(
[key] => US:98011
)
[7] => Array
(
[key] => US:98014
)
[8] => Array
(
[key] => US:98015
)
[9] => Array
(
[key] => US:98019
)
[10] => Array
(
[key] => US:98021
)
)
)
[geo_markets] =>
[excluded_geo_locations] => Array
(
[countries] => Array
(
)
)
[exclusions] =>
[user_adclusters] =>
[interests] =>
[user_os] =>
[user_device] =>
[wireless_carrier] =>
[page_types] => Array
(
[0] => desktopfeed
[1] => mobilefeed
[2] => mobileexternal
[3] => rightcolumn
)
[connections] =>
[excluded_connections] =>
[family_statuses] =>
[friends_of_connections] =>
[flexible_spec] => Array
(
[0] => Array
(
[interests] => Array
(
[0] => Array
(
[id] => 6003277229371
)
)
[behaviors] => Array
(
[0] => Array
(
[id] => 6017447625983
)
)
)
)
[behaviors] =>
[relationship_statuses] =>
[interested_in] =>
[life_events] =>
[location_types] =>
[politics] =>
[markets] =>
[industries] =>
[income] =>
[net_worth] =>
[home_type] =>
[home_ownership] =>
[home_value] =>
[ethnic_affinity] =>
[generation] =>
[household_composition] =>
[moms] =>
[office_type] =>
[education_schools] =>
[education_statuses] =>
[college_years] =>
[education_majors] =>
[work_employers] =>
[work_positions] =>
[locales] =>
[zips] =>
[custom_audiences] =>
[custom_locations] =>
[excluded_custom_audiences] =>
[dynamic_audience_ids] =>
[product_audience_specs] =>
[excluded_product_audience_specs] =>
)
)
[promoted_object] =>
[adlabels] =>
[product_ad_behavior] =>
[execution_options] =>
[configured_status] =>
[effective_status] =>
)
I shortened the targeting for simplicity sake, but there's over 100 postal codes being targetd.
The solution here is that lifetime_budget is denoted in cents, so $64 should be 6400.
You may check if the budget you set is not less of required.
Perform this check at the endpoint:
https://graph.facebook.com/v2.12/act_{ads_account_id}/minimum_budgets
With headers:
Authorization: Bearer {your token with 'ads_management' rights to this account}
Returns:
{
"data": [
{
"currency": "AED",
"min_daily_budget_imp": 300,
"min_daily_budget_video_views": 300,
"min_daily_budget_high_freq": 750,
"min_daily_budget_low_freq": 6000
},
{
"currency": "ARS",
"min_daily_budget_imp": 400,
"min_daily_budget_video_views": 400,
"min_daily_budget_high_freq": 1000,
"min_daily_budget_low_freq": 8000
}
]
}
PS. I see, that my response is 2 years late, but someone may find it useful.
I have following code:
$yt_profiles = $youtube->channels->listChannels('brandingSettings', array(
'mine' => 'true',
));
That returns the following output:
Google_Service_YouTube_ChannelListResponse Object
(
[collection_key:protected] => items
[etag] => "WFPuK6TsnblcGPcnMex79s42ynQ/sTnuE1bHO-tokx_mFFDt1ybN90g"
[eventId] =>
[itemsType:protected] => Google_Service_YouTube_Channel
[itemsDataType:protected] => array
[kind] => youtube#channelListResponse
[nextPageToken] =>
[pageInfoType:protected] => Google_Service_YouTube_PageInfo
[pageInfoDataType:protected] =>
[prevPageToken] =>
[tokenPaginationType:protected] => Google_Service_YouTube_TokenPagination
[tokenPaginationDataType:protected] =>
[visitorId] =>
[modelData:protected] => Array
(
[pageInfo] => Array
(
[totalResults] => 1
[resultsPerPage] => 1
)
[items] => Array
(
[0] => Array
(
[kind] => youtube#channel
[etag] => "WFPuK6TsnblcGPcnMex79s42ynQ/ecOcHFmWyWQ7ToCD7-B1L36b4L4"
[id] => UCQO6uXy5maTpYvSa_yM--Bw
[brandingSettings] => Array
(
[channel] => Array
(
[title] => Vasim Padhiyar
[showRelatedChannels] => 1
[featuredChannelsTitle] => Featured Channels
[featuredChannelsUrls] => Array
(
[0] => UCw-TnDmYDQyjnZ5qpVWUsSA
)
[profileColor] => #000000
)
[image] => Array
(
[bannerImageUrl] => http://s.ytimg.com/yts/img/channels/c4/default_banner-vfl7DRgTn.png
)
[hints] => Array
(
[0] => Array
(
[property] => channel.featured_tab.template.string
[value] => Everything
)
[1] => Array
(
[property] => channel.banner.image_height.int
[value] => 0
)
[2] => Array
(
[property] => channel.modules.show_comments.bool
[value] => True
)
)
)
)
)
)
[processed:protected] => Array
(
)
)
I want to loop through modelData:protected variable to get the list of channels and its items data. Its json object so $yt_profiles->modelData:protected not working while accessing. Please help me to solve this issue.
Thanks in advance
You can reach it as in an array:
print_r ($yt_profiles['modelData']);
Your request:
$yt_profiles = $youtube->channels->listChannels('brandingSettings', array(
'mine' => 'true',
));
To acces to values Channel title for example:
$titleChannel = $yt_profiles["items"][0]["brandingSettings"]["channel"]["title"];
To acces to values bannerImageUrl for example:
$banner = $yt_profiles["items"][0]["brandingSettings"]["image"]["bannerImageUrl"];
Does this help you?
$yt_profiles = $youtube->channels->listChannels('id, brandingSettings', array('mine' => 'true',));
foreach ($yt_profiles['modelData']['items'] as $searchResult) {
switch ($searchResult['kind']) {
case 'youtube#channel':
$channels[]= array('id'=> $searchResult['id'],
'brandingSettings'=> $searchResult['brandingSettings']);
break;
}
}