Created
September 2, 2012 03:20
-
-
Save kosso/3594512 to your computer and use it in GitHub Desktop.
Adding annotations to an App.net post using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// # Adding annotations to an App.net post using PHP | |
// Kosso - alpha.app.net/kosso | |
// Do what you like with it. | |
$ACCESS_TOKEN = 'BLahbLAHl1234BLAHBLAHBLAH'; | |
$post_text = "Hello. This post has annotations"; | |
$ch = curl_init(); | |
// https://github.com/appdotnet/api-spec/blob/master/resources/posts.md#create-a-post | |
curl_setopt($ch, CURLOPT_URL, "https://alpha-api.app.net/stream/0/posts"); | |
$jdata = Array(); | |
$jdata['text'] = $post_text; | |
$annotations = Array(); | |
$annotations['type'] = 'com.your.namespace'; | |
$anno_value = Array(); | |
$anno_value['foo'] = 'bar'; | |
$anno_value['something'] = 'ELSE'; | |
$annotations['value'] = $anno_value; | |
$jdata['annotations'][0] = $annotations; | |
$jdata_string = json_encode($jdata); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $jdata_string); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Authorization: Bearer '.$ACCESS_TOKEN, | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($jdata_string)) | |
); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
echo $data; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment