wesbaker Posted June 11, 2013 Share Posted June 11, 2013 (edited) Hey there, I'm trying to build a Kickstarter workflow that uses their suggestion engine and then directs you to the project's URL. I'm using David Ferguson's PHP Workflow library and basing it heavily off of Google Suggest. I'm retrieving the results just fine and I have the URL, but how do I then pass that URL to the Open URL Output item? require_once('workflows.php'); $wf = new Workflows(); $orig = "{query}"; $json = $wf->request("http://www.kickstarter.com/projects/search.json?search=&term=".urlencode($orig)); $json = json_decode($json); foreach($json->projects as $project) { $url = (preg_match('/<a href="(.*?)\?ref=live/', $project->card_html, $matches)) ? $matches[1] : ''; $wf->result( $project->id, $project->name, $project->name, 'View '.$data.' on Kickstarter', 'icon.png'); } $results = $wf->results(); if ( count( $results ) == 0 ) { $wf->result( 'googlesuggest', $orig, 'No Suggestions', 'No search suggestions found. Search Google for '.$orig, 'icon.png' ); } echo $wf->toxml(); Edited June 11, 2013 by wesbaker Link to comment
wesbaker Posted June 11, 2013 Author Share Posted June 11, 2013 (edited) Ahh, never mind me. I figured it out. The second parameter in $wf->result() is the parameter that gets passed on. Here's the updated code: require_once('workflows.php'); $wf = new Workflows(); $orig = "{query}"; $json = $wf->request("http://www.kickstarter.com/projects/search.json?search=&term=".urlencode($orig)); $json = json_decode($json); foreach($json->projects as $project) { $url = (preg_match('/<a href="(.*?)\?ref=live/i', $project->card_html, $matches)) ? 'http://kickstarter.com'.html_entity_decode($matches[1]) : ''; $funded = (preg_match('/class=".*?funded".*?<strong>(.*?)<\/strong>/is', $project->card_html, $matches)) ? $matches[1] : ''; $pledged = (preg_match('/class="pledged".*?<strong>(.*?)<\/strong>/is', $project->card_html, $matches)) ? $matches[1] : ''; $by = (preg_match('/<span>\s*by(.*?)\s*<\/span>/is', $project->card_html, $matches)) ? trim($matches[1]) : ''; $successful = (stripos($project->card_html, 'project-pledged-successful">') !== FALSE) ? TRUE : FALSE; $failed = (stripos($project->card_html, 'project-failed') !== FALSE) ? TRUE : FALSE; $status = ($successful OR $failed) ? 'Inactive' : 'Active'; $project->name = html_entity_decode($project->name, ENT_QUOTES); $wf->result($project->id, $url, $project->name, "{$status} | by {$by} | {$funded} funded | {$pledged} pledged", 'icon.png'); } $results = $wf->results(); if ( count( $results ) == 0 ) { $wf->result( 'googlesuggest', $orig, 'No Suggestions', 'No search suggestions found. Search Google for '.$orig, 'icon.png' ); } echo $wf->toxml(); And here's the download. Edited February 7, 2014 by wesbaker Link to comment
waitingforgo Posted September 13, 2013 Share Posted September 13, 2013 Has anyone else gotten this workflow to work? I've tried both the download versions and the code pasted above. It's generating the search results correctly, but it's not actually opening the URL. Help? (Thanks in advance!) Link to comment
wesbaker Posted September 13, 2013 Author Share Posted September 13, 2013 (edited) Yeah, a few things changed in Kickstarter's data source, so I had to make some updates. Here's the current download. Edited February 7, 2014 by wesbaker Link to comment
waitingforgo Posted September 13, 2013 Share Posted September 13, 2013 AWESOME! This'll speed up a LOT of my day-to-day tasks... Thank you so much! Link to comment
waitingforgo Posted February 7, 2014 Share Posted February 7, 2014 Sorry to resurrect this topic, but the workflow is broken (I suspect Kickstarter updated their API?). Any chance of an update, please? Link to comment
wesbaker Posted February 7, 2014 Author Share Posted February 7, 2014 (edited) Sorry to resurrect this topic, but the workflow is broken (I suspect Kickstarter updated their API?). Any chance of an update, please? No worries, I was having similar problems. Kickstarter didn't actually change anything, I think the problem was related to Alfred's PHP framework, something changed. It's all fixed now since I'm just using native PHP. The downloads above have been updated. Edited February 7, 2014 by wesbaker waitingforgo 1 Link to comment
waitingforgo Posted February 7, 2014 Share Posted February 7, 2014 No worries, I was having similar problems. Kickstarter didn't actually change anything, I think the problem was related to Alfred's PHP framework, something changed. It's all fixed now since I'm just using native PHP. The downloads above have been updated. Thanks again! It's a huge help once more. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now