1

I am trying to get the orders from Linnwork API. But I am not able to get anything. I am using laravel framework to do this task and here the error I am getting.

EDIT:

No it's not a duplicate question file_get_content is not the main issue for getting the result I can use curl but the problem is linnwork API format its also giving error like "token is wrong". and I have checked the linnwork API documentation to see what's the mandatory fields to pass but there is no luck.

    public function getLinnworkOrders() 
      {

                    date_default_timezone_set('Europe/London');
                    $userId = Auth::id();
                    $tag = Tag::where('user_id', $userId)->where('market', 'Linnwork')->orderBy('created_at', 'desc')->first();
                    $url = 'https://eu1.linnworks.net/api/Orders/GetOpenOrders';
                    $token = $tag->token;
                    $opts = array(
                        'http'=>array(
                         'method'=>"POST",
                           'header'=> "Content-Type: application/x-www-form-urlencoded",
                                "Accept: application/json",
                                "url: https://eu-ext.linnworks.net//api/Orders/GetOpenOrders HTTP/1.1",
                                "Host: eu-ext.linnworks.net",
                                "Connection: keep-alive",
                                "Origin: https://www.linnworks.net",
                                "Accept-Language: en",
                                "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36",
                                "Referer: https://www.linnworks.net/",
                                "Accept-Encoding: gzip, deflate",
                                "Authorization: e2673790a8d866ae30968ea189add96a",
                                'content' => '',
                               'ignore_errors' => true
                            )
                    );
                    $count_json = file_get_contents($opts);
                    $count_json = json_decode($count_json);
                    print_r($count_json);die;

}

And its the error i am getting

"file_get_contents() expects parameter 1 to be a valid path, array given"

deepia
  • 11
  • 4
  • Possible duplicate of [How to post data in PHP using file\_get\_contents?](https://stackoverflow.com/questions/2445276/how-to-post-data-in-php-using-file-get-contents) – Jerodev Jul 17 '18 at 10:03
  • No it's not a duplicate question file_get_content is not the main issue for getting the result I can use curl but the problem is linnwork API format its also giving error like "token is wrong". and I have checked the linnwork API documentation to see what's the mandatory fields to pass but there is no luck. – deepia Jul 17 '18 at 10:21
  • `$url = 'https://eu-ext.linnworks.net/api/Orders/GetOpenOrders'; $context = stream_context_create($opts); $count_json = file_get_contents($url, false, $context);` – Vasyl Zhuryk Jul 17 '18 at 10:26
  • Thanks vasyl now its giving this error {"Code":"-","Message":"Token is missing."} – deepia Jul 17 '18 at 10:39
  • Any help from experts? I am hoping anyone must know linnwork API in laravel framework. it's urgent that's why I am asking again. – deepia Jul 18 '18 at 05:31

0 Answers0