Danny620 Posted April 23, 2012 Share Posted April 23, 2012 error Notice: Undefined property: stdClass::$post_url in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 133 Notice: Undefined property: stdClass::$post_title in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 133 Notice: Undefined property: stdClass::$post_date in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 137 Notice: Undefined variable: fb in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 138 Notice: Undefined variable: tw in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 140 Posted Posted on | Facebook Facebook Twitter Twitter Notice: Undefined property: stdClass::$post_content in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 153 Notice: Undefined property: stdClass::$post_url in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 154 http://www.socialnewsoffice.com/blog_posts?start=0&api_key=b5cbd66dca99c49d1a6c3d ive used this a my json //check if you have curl loaded if(!function_exists("curl_init")) die("cURL extension is not installed"); function Social_News_Office($action, $api_key){ // jSON URL which should be requested $json_url = $action.'&api_key='.api_key.''; // Initializing curl $ch = curl_init( $json_url ); // Configuring curl options $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Content-type: application/json') , ); // Setting curl options curl_setopt_array( $ch, $options ); // Getting results return $result = json_decode(curl_exec($ch)); // Getting jSON result string } $blog_posts = Social_News_Office('http://www.socialnewsoffice.com/blog_posts?start=2&display=6', api_key); foreach($blog_posts as $post) { echo '<!--START OF POST--> <div class="post"> <h2 class="post-heading"><a href="' . BLOG_BASE_URL . 'article/' . $post->post_url . '/">' . strip_tags($post->post_title) . '</a></h2> <!--START OF BLOG INFO--> <p class="meta"> <img alt="Posted" class="meta-img" src="http://www.socialnewsoffice.com/blog-images/time.png"> Posted on ' . $post->post_date . ' | <a target="_blank" href="'.$fb.'" class="socialusers icon Facebook"> <img alt="Facebook" src="http://www.socialnewsoffice.com/blog-images/facebook.png"> Facebook </a> <a target="_blank" href="http://twitter.com/#!/'.$tw.'" class="socialusers icon Twitter"> <img src="http://www.socialnewsoffice.com/blog-images/twitter.png" alt="Twitter" align="baseline"> Twitter </a> </p> <!--START OF POST CONTENT--> <div class="post-content">'; if(!empty($post->article_img)){ echo '<a href="' . BLOG_BASE_URL . 'article/' . $post->post_url . '/"> <img alt="' . strip_tags($post->post_title) . '" class="post-thumbnail" src="' . BLOG_BASE_URL . 'sno-blog/thumbnail.php?file='.$post->article_img.'&width=240&height=160" title="' . strip_tags($post->post_title) . '"></a>'; } echo '<p>' . $post_content = substr(strip_tags($post->post_content,'<p><br><a>'),0,266).'...' . '</p> <a class="read-more" href="' . BLOG_BASE_URL . 'article/' . $post->post_url . '/">Continue reading</a> <div class="clear"></div> </div><!--END OF POST CONTENT--> </div><!--END OF POST-->'; } Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/ Share on other sites More sharing options...
scootstah Posted April 23, 2012 Share Posted April 23, 2012 The objects you are trying to access are located within the "data" object. So it looks like instead of foreach($blog_posts as $post) { you need foreach($blog_posts->data as $post) { Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340002 Share on other sites More sharing options...
Danny620 Posted April 23, 2012 Author Share Posted April 23, 2012 ive tried that with no luck Trying to get property of non-object in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 128 Warning: Invalid argument supplied for foreach() in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 128 Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340009 Share on other sites More sharing options...
scootstah Posted April 24, 2012 Share Posted April 24, 2012 What does var_dump($blog_posts); give you? Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340041 Share on other sites More sharing options...
Danny620 Posted April 24, 2012 Author Share Posted April 24, 2012 array(1) { [0]=> object(stdClass)#4 (2) { ["data"]=> array(1) { [0]=> object(stdClass)#5 (9) { ["blog_id"]=> string(1) "1" ["post_date"]=> string(20) "Tue, 1 February 2011" ["post_title"]=> string(42) "How Old And Young Created Northplanet Ltd." ["article_img"]=> string(48) "http://www.socialnewsoffice.com/uploads/1255.jpg" ["post_content"]=> string(1323) " The story goes that both myself Mike Lane 53 and Danny Mills 18 were quiet passionate about helping people get found on the internet. We first met through being told about each other by a friend of Mike and by Tony Heyes from Business for Breakfast where Danny had set himself and his company as a member of the b4b. After an initial meeting we set each other certain Internet related tasks to perform and were completely blown away when we analysed the results we could achieve through google and Social media. After the Initial meeting in October 2010 it became obvious that our work ethics were very similar and we could work together on a professional level that decided us to incorporate the company In April 2011 Northplanet Ltd. On starting the company our first task was to build a system that could automate the process of updating both Facebook pages and Twitter from writing an informative article around your company’s promotions. This was achieved in record time and was named The Social Media Platform. We have sold this platform across the UK to various companies who wanted to manage there own social media. It also utilises Youtube and Linkedin to add added benefit with Search Engine Optimisation. For more Information please ring either Mike or Danny on 0161 870 6230 " ["tags"]=> string(49) "northplanet, company formation, about northplanet" ["views"]=> string(3) "207" ["categorie_id"]=> string(1) "1" ["post_url"]=> string(29) "company-formation-northplanet" } } ["pages"]=> int(1) } } Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340063 Share on other sites More sharing options...
requinix Posted April 24, 2012 Share Posted April 24, 2012 Then scootstah's idea is still right, but it's $post->data that should be iterated on if at all. $blog_posts is an array of objects and each object has a ->data array of values. foreach ($blog_posts as $post) { foreach ($post->data as $post_data) { However I suspect that ->data will always contain exactly one value, in which case the inner loop isn't necessary and you should just use $post->data[0]->post_url. Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340069 Share on other sites More sharing options...
Danny620 Posted April 24, 2012 Author Share Posted April 24, 2012 Ive done a var dump however it should out put more than one blog check the url please http://www.socialnewsoffice.com/blog_posts?start=0&display=6&api_key=b5cbd66dca99c49d1a6c3d Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340078 Share on other sites More sharing options...
requinix Posted April 24, 2012 Share Posted April 24, 2012 Ive done a var dump however it should out put more than one blog check the url please http://www.socialnewsoffice.com/blog_posts?start=0&display=6&api_key=b5cbd66dca99c49d1a6c3d Then it's the other way around: $blog_posts is an array with only ever one object, so the outer loop wouldn't be necessary and you could foreach ($blog_posts[0]->data as $post) { Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340079 Share on other sites More sharing options...
Danny620 Posted April 24, 2012 Author Share Posted April 24, 2012 this is the json [{ "data":[{ "blog_id":"3", "post_date":"Sat, 14 April 2012", "post_title":"Facebook's New Fan Page Learn How To Use Features", "article_img":"http:\/\/www.socialnewsoffice.com\/uploads\/17963.jpg", "post_content":"<p>This week saw the release of Facebook's latest functionality changes (Timeline for Businesses) that will shape the future of how businesses will market their campaigns, through the social media giant Facebook. A number of marketers are wondering how they will incorporate the new features in an attempt to progress and move forward with their online social media presence.<\/p>\r\n<p>Taking all the key changes in to consideration we have managed to create a guide on how to smoothly move with the times and embrace the new Facebook layout.<\/p>\r\n<p>Please read on below for helpful tips and tricks on how to excel with 'Timeline for Brands'<\/p>\r\n<h2>New Features Announced at the Facebook Marketing Conference:<\/h2>\r\n<p><strong>View and Apps:<\/strong> What was once known as Application pages has changed to 'Tabs'. These can now have customizable images linked with them and the order of them can be changed too. Below you can see from the screenshot what a customized Facebook Timeline looks like.<\/p>\r\n<p><strong>Pinning Content:<\/strong> With this new feature you can 'pin' a post to the very top of your Facebook Timeline. This is Very effective when working on a new campaign and is a great way to entice increased traffic to your tab or application page.<\/p>\r\n<p><strong>Featured 'Starred' Content:<\/strong> This feature allows you to select key content or imagery and extend it so it fits across your entire page. Therefore giving you featured content on your Facebook Timeline and making it more visible.<\/p>\r\n<p><strong>Cover Photos:<\/strong> Cover Photos are another great new feature that allow you to announce your latest campaign, welcome your following community or just simply show visitors to your timeline what you can do. There are some slight flaws with this feature though and will be addressed below.<\/p>\r\n<p><strong>Page Dimensions:<\/strong> Dimensions of application pages has now changed with the release of Facebook Timeline. If you happen to be an SML user then you have all the tools necessary to update your page on your own. If your using Involvers App Suite then those applications will be updated soon.<\/p>\r\n<p><strong>Removal of Default Landing Pages:<\/strong> The commonly used Facebook landing pages have been removed and replaced with various options to allow brands to drive content to application pages. These options allow you to use your cover photo and pinned content to attract users to your personal application pages. Despite the changes it is however still possible to link directly to application pages from ads, posts and outside of Facebook.<\/p>\r\n<h2>Getting Started with Timeline For Brand:<\/h2>\r\n<p>Firstly when accessing and logging in to your New Facebook Brand Page, you will see this admin message displayed below:<\/p>\r\n<p>When will my Page change to the latest design?<\/p>\r\n<p>To see a preview of what your new pages will look like, simply click on the green button at the top of your current pages. A second option is to wait until March 30th 2012 when all pages will be upgraded automatically.<\/p>\r\n<p>Where can I visit to learn more about how to use the new Pages?<\/p>\r\n<p><strong>There are a number of places you can visit to learn all you need to know about Pages:<\/strong><\/p>\r\n<ul>\r\n<li>To find out more about new features, download the Pages Overview guide by clicking here.<\/li>\r\n<li>If your wondering how to get started with Pages then download Facebook's full Pages Product Guide by clicking here.<\/li>\r\n<li>The Pages Learning video allows you to walk through the key features with Facebook's product experts.<\/li>\r\n<li>If you need answers to specific questions, visit Facebook's Help Centre.<\/li>\r\n<\/ul>\r\n<h2>How should I choose a cover photo for my Page?<\/h2>\r\n<p>Firstly select a unique image that represents your page. Facebook itself recommends using a photo of a popular menu item, album artwork or an image of your product being used by someone. You need to experiment with a number of different images that your audience responds positively to. Few key elements of Cover Images:<\/p>\r\n<p><strong>Each Cover image must be at least 399 pixels wide and must not contain the following:<\/strong><\/p>\r\n<ul>\r\n<li>Prices \/ Purchase information and displaying offers such as \"60% off this month\" are not permitted. Also 'Download this from our website' is not allowed.<\/li>\r\n<li>No email addresses, web addresses and any other contact information.<\/li>\r\n<li>References to clicking on or the use of Facebook interface elements such as Like or Share or any other Facebook Features.<\/li>\r\n<li>\"Tell your friends\" or \"Get it now\" or any other calls to action are not allowed in the latest version of Facebook Timeline.<\/li>\r\n<\/ul>\r\n<p>All Timeline cover imagery is public and therefore means anyone visiting your Page will be able to see exactly which image you have chosen. The photos you display must not be deceptive, false or misleading any way that infringes on third party intellectual property. You must also not encourage of incentivize other fellow users, friends or business associates to display the same cover image as yours on personal Timelines.<\/p>\r\n<p>To sum up we are extremely excited about the latest Facebook feature release this week. They constantly deliver new services that are amazing and incredibly innovative to the market place.<\/p>\r\n<p>Here at Northplanet we are commited to provide you with the latest information on the hottest online topics around, to keep you ahead in the game. We would love to hear some feedback from you on the brand new Facebook 'Timeline for Brands' release and invite you to visit our very own <a href=\"https:\/\/www.facebook.com\/northplanet\">Northplanet Facebook Timline page by clicking here.<\/a><\/p>", "tags":"facebook, new fan page", "views":"464", "categorie_id":"2", "post_url":"facebooks-new-fan-page-learn-how-to-use-features" },{ "blog_id":"2", "post_date":"Mon, 23 January 2012", "post_title":"Northplanet Engages New Talent!", "article_img":"http:\/\/www.socialnewsoffice.com\/uploads\/1263.jpg", "post_content":"<p>Big piece of news for the start of 2012 is…… I have landed a full time role in a leading Web Design and Development agency based in Greater Manchester. After a successful interview on New Years Eve, I had another reason to celebrate bringing in the New Year!!<\/p>\r\n<p>I was first attracted to Northplanet when I came across there website when searching for jobs online. I was impressed not only by the standard of web work but the direction the company where going in. Growing year by year and providing exceptional web solutions for a number of businesses spread across the UK.<\/p>\r\n<p>I contacted them instantly and have done some freelance work a few times in the last year for Directors Danny and Mike and was able to build up a strong working relationship that helped me land the interview at the end of the year.<\/p>\r\n<p>I begin my career at Northplanet next week and will post all offers\/promotions and deals on here in the nearfuture.<\/p>\r\n<p>Time to sign off and prepare for my new career!!<\/p>", "tags":"engages new talent, new staff, northplanet staff, christian thomas mizon", "views":"271", "categorie_id":"1", "post_url":"northplanet-engages-new-talent" },{ "blog_id":"1", "post_date":"Tue, 1 February 2011", "post_title":"How Old And Young Created Northplanet Ltd.", "article_img":"http:\/\/www.socialnewsoffice.com\/uploads\/1255.jpg", "post_content":"<p>The story goes that both myself Mike Lane 53 and Danny Mills 18 were quiet passionate about helping people get found on the internet. We first met through being told about each other by a friend of Mike and by Tony Heyes from Business for Breakfast where Danny had set himself and his company as a member of the b4b.<\/p>\r\n<p>After an initial meeting we set each other certain Internet related tasks to perform and were completely blown away when we analysed the results we could achieve through google and Social media. After the Initial meeting in October 2010 it became obvious that our work ethics were very similar and we could work together on a professional level that decided us to incorporate the company In April 2011 Northplanet Ltd.<\/p>\r\n<p>On starting the company our first task was to build a system that could automate the process of updating both Facebook pages and Twitter from writing an informative article around your company’s promotions. This was achieved in record time and was named The Social Media Platform. We have sold this platform across the UK to various companies who wanted to manage there own social media.<\/p>\r\n<p>It also utilises Youtube and Linkedin to add added benefit with Search Engine Optimisation. For more Information please ring either Mike or Danny on 0161 870 6230<\/p>", "tags":"northplanet, company formation, about northplanet", "views":"207", "categorie_id":"1", "post_url":"company-formation-northplanet" }], "pages":"1" }] Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340084 Share on other sites More sharing options...
Danny620 Posted April 24, 2012 Author Share Posted April 24, 2012 thank you so much ive sorted it thanks guys so happy Quote Link to comment https://forums.phpfreaks.com/topic/261508-undefined-property-stdclasspost_url/#findComment-1340085 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.