{"action":"created","issue":{"url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/284","repository_url":"https://api.github.com/repos/sendgrid/sendgrid-php","labels_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/284/labels{/name}","comments_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/284/comments","events_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/284/events","html_url":"https://github.com/sendgrid/sendgrid-php/issues/284","id":174375829,"number":284,"title":"401 Unauthorized","user":{"login":"xorb0ss","id":9213716,"avatar_url":"https://avatars.githubusercontent.com/u/9213716?v=3","gravatar_id":"","url":"https://api.github.com/users/xorb0ss","html_url":"https://github.com/xorb0ss","followers_url":"https://api.github.com/users/xorb0ss/followers","following_url":"https://api.github.com/users/xorb0ss/following{/other_user}","gists_url":"https://api.github.com/users/xorb0ss/gists{/gist_id}","starred_url":"https://api.github.com/users/xorb0ss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xorb0ss/subscriptions","organizations_url":"https://api.github.com/users/xorb0ss/orgs","repos_url":"https://api.github.com/users/xorb0ss/repos","events_url":"https://api.github.com/users/xorb0ss/events{/privacy}","received_events_url":"https://api.github.com/users/xorb0ss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-31T20:53:33Z","updated_at":"2016-08-31T20:56:00Z","closed_at":null,"body":"Hey,\r\n\r\nI have this code for a contact form, however upon submission, I get a **401** from sendgrid\r\n\r\n> echo $response->statusCode(); == 401\r\n\r\n`    \r\n     <?php\r\n      require 'vendor/autoload.php';\r\n\r\n      $apiKey = getenv('SENDGRID_API_KEY');\r\n      $sendgrid = new \\SendGrid($apiKey);\r\n\r\n\tif (isset($_POST[\"submit\"])) {\r\n\t\t$name = $_POST['name'];\r\n\t\t$email = $_POST['email'];\r\n\t\t$message = $_POST['message'];\r\n\t\t\r\n\t\tif (!$_POST['name']) {\r\n\t\t\t$errName = 'Please enter your name';\r\n\t\t}\r\n\t\t\r\n\t\tif (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {\r\n\t\t\t$errEmail = 'Please enter a valid email address';\r\n\t\t}\r\n\t\t\r\n\t\tif (!$_POST['message']) {\r\n\t\t\t$errMessage = 'Please enter your message';\r\n\t\t}\r\n\t\t\r\nif (!$errName && !$errEmail && !$errMessage) {\r\n\t$from = new SendGrid\\Email(null, \"$name\");\r\n\t$subject = \"Hello World from the SendGrid PHP Library!\";\r\n\t$to = new SendGrid\\Email(null, \"myemail@email.com\");\r\n\t$content = new SendGrid\\Content(\"text/plain\", \"$message\");\r\n\t$mail = new SendGrid\\Mail($from, $subject, $to, $content);\r\n\r\n\t$response = $sg->client->mail()->send()->post($mail);\r\n\techo $response->statusCode();\r\n\techo $response->headers();\r\n\techo $response->body();\r\n}\r\n\t}\r\n?>`\r\n\r\nAny ideas?"},"comment":{"url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/comments/243898660","html_url":"https://github.com/sendgrid/sendgrid-php/issues/284#issuecomment-243898660","issue_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/284","id":243898660,"user":{"login":"thinkingserious","id":146695,"avatar_url":"https://avatars.githubusercontent.com/u/146695?v=3","gravatar_id":"","url":"https://api.github.com/users/thinkingserious","html_url":"https://github.com/thinkingserious","followers_url":"https://api.github.com/users/thinkingserious/followers","following_url":"https://api.github.com/users/thinkingserious/following{/other_user}","gists_url":"https://api.github.com/users/thinkingserious/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkingserious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkingserious/subscriptions","organizations_url":"https://api.github.com/users/thinkingserious/orgs","repos_url":"https://api.github.com/users/thinkingserious/repos","events_url":"https://api.github.com/users/thinkingserious/events{/privacy}","received_events_url":"https://api.github.com/users/thinkingserious/received_events","type":"User","site_admin":false},"created_at":"2016-08-31T20:56:00Z","updated_at":"2016-08-31T20:56:00Z","body":"@xorb0ss,\r\n\r\nThis means your API Key either is not valid or set properly.\r\n\r\nFirst, I would suggest that you print the value of `$apiKey` and ensure it is set properly.\r\n\r\nIf your API Key is set properly, please reach out to https://support.sendgrid.com to check on the status of your API Key's permissions.\r\n\r\nThank you!"}}
{"actor":{"display_login":"thinkingserious"}}