Skip to content

Instantly share code, notes, and snippets.

@jwebster
Created June 7, 2019 11:10
Show Gist options
  • Select an option

  • Save jwebster/f72d91ce9b6f1088c25c86498ac43723 to your computer and use it in GitHub Desktop.

Select an option

Save jwebster/f72d91ce9b6f1088c25c86498ac43723 to your computer and use it in GitHub Desktop.
sheepCRM API - PHP login example
$url = 'https://api.sheepcrm.com/api/v1/sheep-app/user/auth/';
$flock = 'example';
$sheep_token_name = 'my_third_party_app';
$post_data['email'] = $email;
$post_data['password'] = $password;
$post_data['token_name'] = $sheep_token_name;
$post_data['token_timeout'] = 43200;
$post_data['secure_hash'] = time();
$userAgent = $_SERVER['HTTP_USER_AGENT'];
// Initialize cURL
$ch = curl_init();
// Set URL on which you want to post the Form and/or data
curl_setopt($ch, CURLOPT_URL, $url);
//Header fields
curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: '.$userAgent));
// Data to be posted
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
// Pass TRUE or 1 if you want to wait for and catch the response against the request made
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// For Debug mode; shows up any error encountered during the operation
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Execute the request
$response = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment