我创建了一个读取外部API的函数,它创建了一个带有一些自定义字段的自定义post“作业”。对于开发,我在一个短代码中创建了它,并可以重新加载页面来触发它。工作正常。我现在正试图将其转换为一个插件,该插件带有一个按钮触发的选项页面。运行导入时,会出现两个错误:
未定义属性:stdClass::/srv/www/careers/public\\u html/wp content/plugins/demand api remote old/functions中的$jobs\\u description。php第89行
正在尝试在/srv/www/careers/public\\u html/wp-content/plugins/demand-api-remote-old/functions中获取非对象的属性“name”。php在线90
JSON数据的格式如下:
{
"id": 182966,
"name": "Client Advisor",
"created_at": "2018-03-12T17:56:28.542Z",
"status": "Open",
"employment_status": "Full Time - salary",
"job_description": "<p><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\"><span style=\\"color:black\\">Working at Schomp is more than just an automotive career. Employers may claim to “promote from within,” but we mean it; most of our executive team started as lot techs, client advisors, detailers, and service advisors. Every decision we make hinges on two pillars: being right for our employees, and being right for our customers. If you’re ready to finally have an automotive job where you know you’re making a difference at any level, apply now.</span></span></span></p>\\n\\n<p><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\"><span style=\\"color:black\\">As a <strong>Client Advisor</strong>, you’ll be at the forefront of the automotive industry. You will be responsible for generating sales of new vehicles to prospective purchasers, maximizing dealership profitability and maintaining an exceptional standard of customer care. Our ideal candidate is highly motivated and with a competitive edge. You will enjoy going the extra mile for your customers, and thrive on working in a competitive team environment. You will be a problem solver who sees things in an innovative fashion, and can make the complex seem simple. You will have the ability to create a positive buying experience for your customers along with a track record of success.</span></span></span></p>\\n\\n<p><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\"><span style=\\"color:black\\">You will have the opportunity to work with a team of people who share your values, and to inspire them to meet and exceed their customers’ expectations every day. You will receive ongoing training and career development opportunities aligned with your personal goals and aspirations. </span></span></span></p>\\n\\n<p> </p>\\n\\n<p><strong><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\"><span style=\\"color:black\\">We Offer:</span></span></span></strong></p>\\n\\n<ul>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Competitive compensation package that rewards high-performers</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Medical, Dental and Prescription coverage</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Life Insurance</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">401(k) with company match</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Employee discounts on vehicle purchases, parts and service</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Paid time-off</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Supplemental benefit plans including short-term disability, long-term disability, supplemental life insurance and All-State Insurance products</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Comprehensive employee recognition programs</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Continued training through Schomp Automotive Group and the manufacturer</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Opportunities for career advancement</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Fully equipped workout gym with free on-site personal trainer and yoga instructor!</span></span></span></li>\\n</ul>\\n\\n<p><br />\\n<span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\"><span style=\\"color:black\\"><strong>Responsibilities:</strong></span></span></span></p>\\n\\n<ul>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Initiating and maintaining relationships with customers</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Greet and guide customer as they appear on the lot to proceed into the sales process</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Enhance the sales process by demonstrating the vehicles features on the lot</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Taking customers through a thorough needs analysis, making suitable product recommendations and organizing test drives</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Accurately logging activities on the internal lead management system</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Conducting business development and networking activities to generate sales</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Assist management to increase sales by inspecting the lot’s vehicles daily reporting any problems to the General Manager</span></span></span></li>\\n</ul>\\n\\n<p> </p>\\n\\n<p><strong><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\"><span style=\\"color:black\\">Qualifications: </span></span></span></strong></p>\\n\\n<ul>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Prior automotive sales experience not necessary. We are willing to train and develop the right person.</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Individuals with a background in the hospitality and/or restaurant industry are strongly encouraged to apply</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Experience representing a luxury brand helpful but not necessary</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Self-driven and motivated to achieve results</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Excellent communication skills</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Experience generating and/or building a loyal client base highly regarded</span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Knowledge of current trends and news, plus a strong desire to learn more and do more </span></span></span></li>\\n\\t<li><span style=\\"color:black\\"><span style=\\"font-size:14.0pt\\"><span style=\\"font-family:"Helvetica Light",sans-serif\\">Willing to submit to a background check & drug screen prior to employment</span></span></span></li>\\n</ul>\\n",
"locations": [
{
"city": "Highlands Ranch",
"state": "CO"
}
],
"remote": false,
"blind_posted": false,
"job_family": {
"id": 1,
"name": "Sales",
"shorten": true,
"arrange": 13
},
"careersite_order": 0,
"career_site_url": "https://careers.hireology.com/schompautomotive/182966/description",
"application_path": "/careers/182966/application",
"career_site_path": "/schompautomotive/182966/description",
"organization": {
"id": 7587,
"name": "Schomp Automotive",
"type": "Corporate"
},
"seo_description": "Working at Schomp is more than just an automotive career. Employers may claim to “promote from within,” but we mean it; most of our executive team started as lo...",
"seo_keywords": "Schomp Automotive, Schomp Automotive jobs, careers at Schomp Automotive, Auto jobs, careers in Auto, Highlands Ranch jobs, Colorado jobs, Sales jobs, Client Advisor",
"seo_page_title": "Client Advisor | Highlands Ranch, CO | Schomp Automotive",
"one_click_apply": false,
},
此处是我的错误代码:
{
//$app_token = $attributes[\'app_token\'];
$limit = \'100\';
$request_uri = \'https://api.hireology.com/v2/public/careers/schompautomotive?page_size=\' . $limit;
$request = wp_remote_get( $request_uri );
if( is_wp_error( $request ) || \'200\' != wp_remote_retrieve_response_code( $request ) ) {
return;
}
$jobs = json_decode( wp_remote_retrieve_body( $request ) );
if( empty( $jobs ) ) {
return;
}
ob_start();
// print_array($jobs);
foreach( $jobs->data as $jobs ) {
$jobs_id = $jobs->id;
$jobs_title = $jobs->name;
$open_date = $jobs->created_at;
$jobs_status = $jobs->status;
$jobs_type = $jobs->employment_status;
$jobs_description = $jobs->jobs_description;
$jobs_family = $jobs->jobs_family->name;
$jobsurl = $jobs->career_site_url;
$jobs_app_path = $jobs->application_path;
foreach ($jobs->locations as $location ){
$jobs_location = $location->city;
}
$jobs_query = get_posts(array(
\'posts_per_page\' => -1,
\'post_type\' => \'jobs\'
));
$post_id = -1;
if( null == get_page_by_title($jobs_title, OBJECT, \'jobs\') ) {
// Insert the post into the database.
$post_id = wp_insert_post(
array(
\'post_type\' => \'jobs\',
\'post_title\' => $jobs_title,
\'post_content\' => $jobs_description,
\'post_status\' => \'publish\',
\'post_author\' => 1,
//\'post_category\' => array( 8,39 )
));
update_field(\'field_5cfeb71e121d6\', $jobs_id, $post_id);
update_field(\'field_5cfeb738121d7\', $jobs_title, $post_id);
update_field(\'field_5d0a57c0c3c62\', $open_date, $post_id);
update_field(\'field_5cfeb746121d8\', $jobs_status, $post_id);
update_field(\'field_5cfeb769121d9\', $jobs_type, $post_id);
update_field(\'field_5cfeb782121da\', $jobs_description, $post_id);
update_field(\'field_5cfeb79c121db\', $jobs_location, $post_id);
update_field(\'field_5cfeb7ad121dc\', $jobs_family, $post_id);
update_field(\'field_5cfeb88cd384c\', $jobsurl, $post_id);
update_field(\'field_5cfeb8b7d384d\', $jobs_app_path, $post_id);
} else {
$post_id = -2;
}
echo \'<div id="message" class="updated fade"><p>\'
.\'Jobs Importer Finished\' . \'</p></div>\';
}
}
如果我使用一个短代码,类似的代码可以完美无误地工作。有人能告诉我为什么我的对象不是对象吗?
这里是$jobs
在里面dump_var
(注:为了更好的可读性,我删除了关键“工作描述”中的数据)。我想真正的问题是,我需要帮助了解为什么我可以在短代码中横切数据,但当我通过“选项”页面按钮进行操作时,它会变为数组vs对象。
stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[id] => 182966
[name] => Client Advisor
[created_at] => 2018-03-12T17:56:28.542Z
[status] => Open
[employment_status] => Full Time - salary
[job_description] =>
[locations] => Array
(
[0] => stdClass Object
(
[city] => Highlands Ranch
[state] => CO
)
)
[remote] =>
[blind_posted] =>
[job_family] => stdClass Object
(
[id] => 1
[name] => Sales
[shorten] => 1
[arrange] => 13
)
[careersite_order] => 0
[career_site_url] => https://careers.hireology.com/schompautomotive/182966/description
[application_path] => /careers/182966/application
[career_site_path] => /schompautomotive/182966/description
[organization] => stdClass Object
(
[id] => 7587
[name] => Schomp Automotive
[type] => Corporate
)
[seo_description] => Working at Schomp is more than just an automotive career. Employers may claim to “promote from within,” but we mean it; most of our executive team started as lo...
[seo_keywords] => Schomp Automotive, Schomp Automotive jobs, careers at Schomp Automotive, Auto jobs, careers in Auto, Highlands Ranch jobs, Colorado jobs, Sales jobs, Client Advisor
[seo_page_title] => Client Advisor | Highlands Ranch, CO | Schomp Automotive
[one_click_apply] =>
[third_party_service_data] => stdClass Object
(
[indeed_apply] => stdClass Object
(
[indeed-apply-apitoken] => b20e5f8adcfd3b39b7c8cf9d2afae9a143a7f431f32a8011b8f23cf62d59b4e1
[indeed-apply-jobid] => 182966
[indeed-apply-jobtitle] => Client Advisor
[indeed-apply-jobcompanyname] => Schomp Automotive
[indeed-apply-joblocation] => stdClass Object
(
[id] => 1151656
[city] => Highlands Ranch
[created_at] => 2019-02-13T00:24:15.575Z
[updated_at] => 2019-02-13T00:24:15.575Z
[job_id] => 182966
[state_id] => 6
[zip_code] => 80129
[address] =>
)
[indeed-apply-posturl] => https://app.hireology.com/service_endpoints/job/182966/application_form?ref=career_site&ref_m=indeed+apply
[indeed-apply-questions] => https://app.hireology.com/service_endpoints/job/182966/application_form/questions?updated=1530565694
[indeed-apply-phone] => required
[indeed-apply-coverletter] => optional
[indeed-apply-name] => firstlastname
[indeed-apply-jobmeta] => job-meta-button top
)
)
)
[1] => stdClass Object
(
[id] => 182972
[name] => Certified Service Technician
[created_at] => 2018-03-12T18:07:14.816Z
[status] => Open
[employment_status] => Full Time - salary
[job_description] =>
\'\'\'