Last active
August 29, 2015 14:19
-
-
Save banago/10a404b63627f7cd58c7 to your computer and use it in GitHub Desktop.
PHP script for working with Convo's custom feed API.
This file contains hidden or 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 | |
/* Convo Custom Feed API | |
* | |
* This is the PHP version of the python example script Convo offers on their website: | |
* https://www.convo.com/developer_center/api/imported_feed_api.py | |
*/ | |
function add_link_in_feed($resource_id, $url, $title, $description, $image, $site_name) { | |
global $access_key_id, $secret_access_key; | |
$params = http_build_query(['resource_id' => $resource_id, 'url' => $url, 'title' => $title, 'description' => $description, 'image' => $image, 'site_name' => $site_name ]); | |
$stringToSign = $params; | |
$signature = hash_hmac('sha1', $stringToSign, $secret_access_key); | |
$headers = ["Content-type: application/x-www-form-urlencoded", "Authorization: " . $access_key_id . ":" . $signature]; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://app.convo.com/api/v1/importedfeed"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_HEADER, FALSE); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $params); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
print_r($response); | |
} | |
$access_key_id = 'api-id-goes-here'; # Available in Convo Admin Panel -> Imported Feeds | |
$secret_access_key = 'api-key-goes-here'; # Available in Convo Admin Panel -> Imported Feeds | |
$resource_id = 'stm-goes-here'; # Available in Convo Imported Feed Settings View | |
$url = 'http://wplancer.com/'; | |
$title = 'News and resources for people that make a living with WordPress. Curated by Baki Goxhaj, the WordPress Freelancer'; | |
$description = 'WPlancer is run by Baki Goxhaj. He has been developing WordPress themes since 2006 and turned it into a profession by the end of 2007.'; | |
$image = ''; | |
$site_name = 'WPlancer'; | |
add_link_in_feed($resource_id, $url, $title, $description, $image, $site_name); | |
exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment